Actually comparing the password when granting a token is important

This commit is contained in:
Alex Mikhalev 2018-07-02 15:25:35 -06:00
parent 2baca5fdd0
commit 853770a9e8

View File

@ -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");
} }
} }