Login: handle pending approval users
This commit is contained in:
parent
1c2ca9fa57
commit
9550cf2bf3
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue