mirror of
https://github.com/dec0dOS/zero-ui.git
synced 2025-07-05 20:41:43 -07:00
commit
4a5f8469b3
30 changed files with 555 additions and 97 deletions
|
@ -10,7 +10,7 @@ const loginLimiter = rateLimit({
|
|||
max: Number(process.env.ZU_LOGIN_LIMIT_ATTEMPTS) || 50, // limit each IP to 50 requests per windowMs
|
||||
message: {
|
||||
status: 429,
|
||||
error: "Too many login attempts, please try again in 15 minutes.",
|
||||
error: "tooManyAttempts",
|
||||
},
|
||||
});
|
||||
|
||||
|
|
|
@ -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("Invalid username or password")); // If return "user not found" someone can do a user listing
|
||||
if (!user.value()) return callback(new Error("logInFailed")); // 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 username or password"));
|
||||
return callback(new Error("logInFailed"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue