Skip to content

Always returning a 404 after redirection #140

@Nickforall

Description

@Nickforall

Whenever I do a redirect, I get a 404 on the page redirected to, even though the url exists when I reload the exact same url. I have checked the http responses of /auth/login and the page redirected to, and they are both valid.

This is what my handler looks like at the moment.

impl AuthenticationController {
    // Route: POST /auth/login
    pub fn login(req: &mut Request) -> IronResult<Response> {
        let url: Url;

        if try!(req.session().get::<middleware::sessions::Login>()).is_some() {
            url = url_for!(req, "index", "status" => "already_loggedin");
        } else {
            if User::authenticate("hello@nickforall.nl", "password") {
                url = url_for!(req, "index", "status" => "success");
            } else {
                url = url_for!(req, "index", "status" => "failure");
            }
        }

        Ok(Response::with((status::Found, Redirect(url.clone()))))
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions