AuthController: use Validator system for unknown user on login
This commit is contained in:
parent
6eacfdcffa
commit
6a65ec723d
@ -6,6 +6,7 @@ import ModelFactory from "../db/ModelFactory";
|
|||||||
import User from "./models/User";
|
import User from "./models/User";
|
||||||
import UserPasswordComponent from "./password/UserPasswordComponent";
|
import UserPasswordComponent from "./password/UserPasswordComponent";
|
||||||
import UserNameComponent from "./models/UserNameComponent";
|
import UserNameComponent from "./models/UserNameComponent";
|
||||||
|
import {UnknownRelationValidationError} from "../db/Validator";
|
||||||
|
|
||||||
export default class AuthController extends Controller {
|
export default class AuthController extends Controller {
|
||||||
public getRoutesPrefix(): string {
|
public getRoutesPrefix(): string {
|
||||||
@ -103,10 +104,9 @@ export default class AuthController extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected async redirectToRegistration(req: Request, res: Response, identifier: string): Promise<void> {
|
protected async redirectToRegistration(req: Request, res: Response, identifier: string): Promise<void> {
|
||||||
req.flash('register_identifier', identifier);
|
const error = new UnknownRelationValidationError(User.table, 'identifier');
|
||||||
req.flash('info', `User with identifier "${identifier}" not found.`);
|
error.thingName = 'identifier';
|
||||||
res.redirect(Controller.route('auth', undefined, {
|
error.value = identifier;
|
||||||
redirect_uri: req.query.redirect_uri?.toString() || undefined,
|
throw error;
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user