Login: handle pending approval users

This commit is contained in:
Alice Gaudon 2020-07-29 15:01:06 +02:00
parent 1c2ca9fa57
commit 9550cf2bf3
1 changed files with 12 additions and 5 deletions

View File

@ -45,11 +45,18 @@ export default class AuthController extends _AuthController {
if (e instanceof AuthError) {
Throttler.throttle('login_failed_attempts_user', 3, 180000, user.as(UserNameComponent).name!, 1000, 60000);
Throttler.throttle('login_failed_attempts_ip', 5, 60000, req.ip, 1000, 60000);
const bag = new ValidationBag();
const err = new InvalidFormatValidationError('Invalid password.');
err.thingName = 'password';
bag.addMessage(err)
throw bag;
if (e instanceof PendingApprovalAuthError) {
req.flash('error', 'Your account is still being reviewed.');
res.redirectBack();
return;
} else {
const bag = new ValidationBag();
const err = new InvalidFormatValidationError('Invalid password.');
err.thingName = 'password';
bag.addMessage(err)
throw bag;
}
} else {
throw e;
}