|
|
@@ -1,6 +1,6 @@
|
|
|
import Express, {Request, Response} from "express"
|
|
|
-import gUserService from "../services/userService";
|
|
|
import ConfigurationManager from "../config";
|
|
|
+import gAuthenticationService from "../services/authenticationService";
|
|
|
|
|
|
export class UnauthorizedUser extends Error {
|
|
|
private isLoggedIn: boolean;
|
|
|
@@ -105,8 +105,8 @@ export class SecurityRequirement {
|
|
|
gSessionManager.remove(req.cookies?.[COOKIE_SESSION]);
|
|
|
res.cookie(COOKIE_SESSION, null);
|
|
|
}
|
|
|
- public static tryLogin(req: Request, res: Response, username: string, password: string): boolean {
|
|
|
- if (!gUserService.tryLogin(username, password))
|
|
|
+ public static async tryLogin(req: Request, res: Response, username: string, password: string, totp: string|undefined): Promise<boolean> {
|
|
|
+ if (!await gAuthenticationService.getAuthenticationLoader().tryLogin(username, password, totp))
|
|
|
return false;
|
|
|
this.setLoggedUser(req, res);
|
|
|
return true;
|
|
|
@@ -141,8 +141,8 @@ export class HtmlController {
|
|
|
return res.redirect("/");
|
|
|
}
|
|
|
|
|
|
- private static postLogin(req: Request, res: Response) {
|
|
|
- if (SecurityRequirement.tryLogin(req, res, req.body.username, req.body.password)) {
|
|
|
+ private static async postLogin(req: Request, res: Response) {
|
|
|
+ if (await SecurityRequirement.tryLogin(req, res, req.body.username, req.body.password, undefined)) {
|
|
|
res.redirect("/");
|
|
|
return;
|
|
|
}
|