Actually comparing the password when granting a token is important
This commit is contained in:
parent
2baca5fdd0
commit
853770a9e8
@ -104,13 +104,13 @@ export function authentication(state: ServerState) {
|
|||||||
}
|
}
|
||||||
const user = await User.loadByUsername(state.database, username);
|
const user = await User.loadByUsername(state.database, username);
|
||||||
if (!user) {
|
if (!user) {
|
||||||
throw new ApiError(401, "User does not exist");
|
throw new ApiError(400, "User does not exist");
|
||||||
}
|
}
|
||||||
const passwordMatches = user.comparePassword(password);
|
const passwordMatches = await user.comparePassword(password);
|
||||||
if (passwordMatches) {
|
if (passwordMatches) {
|
||||||
return user;
|
return user;
|
||||||
} else {
|
} else {
|
||||||
throw new ApiError(400, "User does not exist");
|
throw new ApiError(401, "Invalid user credentials");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user