Files
lolympus-tournament-support/apps/api/src/modules/auth/auth.middleware.ts
T
2026-04-12 22:17:00 +09:00

19 lines
595 B
TypeScript

import { Injectable, NestMiddleware } from '@nestjs/common';
import type { NextFunction, Request, Response } from 'express';
import { AuthService } from './auth.service';
import './auth-request';
@Injectable()
export class AuthMiddleware implements NestMiddleware {
constructor(private readonly authService: AuthService) {}
public async use(req: Request, _res: Response, next: NextFunction) {
const fallback = await this.authService.resolveDevFallbackFromRequest(req);
if (fallback) {
req.user = fallback.user;
req.identity = fallback.identity;
}
next();
}
}