implement account locking on too many attempts and unlocking after time window
This commit is contained in:
@@ -35,9 +35,15 @@ async function login(args) {
|
||||
if (!userDoc || (args.collection.config.auth.emailVerification && !userDoc._verified)) {
|
||||
throw new AuthenticationError();
|
||||
}
|
||||
if (userDoc && userDoc.isLocked) {
|
||||
throw new AuthenticationError();
|
||||
}
|
||||
const authResult = await userDoc.authenticate(password);
|
||||
|
||||
if (!authResult.user) {
|
||||
if (authResult.user) {
|
||||
await authResult.user.resetLoginAttempts();
|
||||
} else {
|
||||
await userDoc.incLoginAttempts();
|
||||
throw new AuthenticationError();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user