diff --git a/package.json b/package.json index 9464529..815e475 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wms-core", - "version": "0.21.2", + "version": "0.21.3", "description": "Node web application framework and toolbelt.", "repository": "https://gitlab.com/ArisuOngaku/wms-core", "author": "Alice Gaudon ", diff --git a/src/auth/AuthComponent.ts b/src/auth/AuthComponent.ts index a80bd63..097fef8 100644 --- a/src/auth/AuthComponent.ts +++ b/src/auth/AuthComponent.ts @@ -15,7 +15,7 @@ export default class AuthComponent extends ApplicationComponent { public async init(router: Router): Promise { router.use(async (req, res, next) => { req.authGuard = this.authGuard; - res.locals.user = await (await req.authGuard.getProof(req))?.getResource(); + req.models.user = res.locals.user = await (await req.authGuard.getProof(req))?.getResource(); next(); }); } @@ -31,7 +31,6 @@ export const REQUIRE_REQUEST_AUTH_MIDDLEWARE = async (req: Request, res: Respons return; } - req.models.user = await proof.getResource(); next(); }; @@ -39,7 +38,6 @@ export const REQUIRE_AUTH_MIDDLEWARE = async (req: Request, res: Response, next: // Via request let proof = await req.authGuard.isAuthenticatedViaRequest(req); if (proof) { - req.models.user = await proof.getResource(); next(); return; } @@ -54,7 +52,6 @@ export const REQUIRE_AUTH_MIDDLEWARE = async (req: Request, res: Response, next: return; } - req.models.user = await proof.getResource(); next(); }; export const REQUIRE_GUEST_MIDDLEWARE = async (req: Request, res: Response, next: NextFunction): Promise => {