Fixed a bug where credentials were not being validated
This commit is contained in:
parent
f0b360e3d0
commit
e0b3ea4b98
2 changed files with 6 additions and 1 deletions
|
@ -64,6 +64,7 @@ impl<'r> rocket::response::Responder<'r> for Error {
|
||||||
build
|
build
|
||||||
.status(match self.0 {
|
.status(match self.0 {
|
||||||
ErrorKind::FileNotFound => rocket::http::Status::NotFound,
|
ErrorKind::FileNotFound => rocket::http::Status::NotFound,
|
||||||
|
ErrorKind::IncorrectCredentials => rocket::http::Status::Unauthorized,
|
||||||
_ => rocket::http::Status::InternalServerError,
|
_ => rocket::http::Status::InternalServerError,
|
||||||
})
|
})
|
||||||
.ok()
|
.ok()
|
||||||
|
|
|
@ -233,7 +233,11 @@ fn auth(
|
||||||
credentials: Json<AuthCredentials>,
|
credentials: Json<AuthCredentials>,
|
||||||
mut cookies: Cookies,
|
mut cookies: Cookies,
|
||||||
) -> Result<Json<AuthOutput>, errors::Error> {
|
) -> Result<Json<AuthOutput>, errors::Error> {
|
||||||
user::auth::<DB>(&db, &credentials.username, &credentials.password)?;
|
|
||||||
|
if !user::auth::<DB>(&db, &credentials.username, &credentials.password)? {
|
||||||
|
return Err(errors::Error::from(errors::ErrorKind::IncorrectCredentials))
|
||||||
|
}
|
||||||
|
|
||||||
cookies.add_private(get_auth_cookie(&credentials.username));
|
cookies.add_private(get_auth_cookie(&credentials.username));
|
||||||
|
|
||||||
let auth_output = AuthOutput {
|
let auth_output = AuthOutput {
|
||||||
|
|
Loading…
Add table
Reference in a new issue