fix bug on api.rs, only insert username in the session if authentication was successful

This commit is contained in:
João Oliveira 2017-10-13 18:55:53 +01:00
parent 953dea1929
commit 130aa70c2b

View file

@ -237,8 +237,10 @@ impl Handler for AuthHandler {
if let Some(ref password) = auth.password {
auth_success =
user::auth(self.db.deref(), auth.username.as_str(), password.as_str())?;
req.extensions
.insert::<SessionKey>(Session { username: auth.username.clone() });
if auth_success {
req.extensions
.insert::<SessionKey>(Session { username: auth.username.clone() });
}
}
}
}