mirror of
https://github.com/dec0dOS/zero-ui.git
synced 2025-07-06 13:01:46 -07:00
feat: login-limiter
This commit is contained in:
parent
60777f5165
commit
7dd6f3729b
4 changed files with 14 additions and 8 deletions
|
@ -8,12 +8,12 @@ export async function authorize(username, password, callback) {
|
|||
throw err;
|
||||
}
|
||||
const user = users.find({ username: username });
|
||||
if (!user.value()) return callback(new Error("Cannot find user"));
|
||||
if (!user.value()) return callback(new Error("Invalid username or password")); // If return "user not found" someone can do a user listing
|
||||
const verified = await verifyHash(password, user.value()["password_hash"]);
|
||||
if (verified) {
|
||||
return callback(null, user.value());
|
||||
} else {
|
||||
return callback(new Error("Invalid password"));
|
||||
return callback(new Error("Invalid username or password"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue