feat(api): add auth guards
This commit is contained in:
1 parent
3a86676a12
commit
d4b790fd86
16 files changed
+592
No files matched your search
@@ -0,0 +1,18 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user