Merge pull request #182 from aruznieto/i18n

feat: i18n
This commit is contained in:
Aliaksei 2023-10-19 19:52:38 +01:00 committed by GitHub
commit 4a5f8469b3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 555 additions and 97 deletions

View file

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

View file

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