Ai Search finished, some makeup changes, guards, brokerSearch

This commit is contained in:
2024-08-28 15:41:59 +02:00
parent 8721be4a90
commit ede8b66d83
20 changed files with 139 additions and 53 deletions

View File

@@ -0,0 +1,18 @@
import { CanActivate, ExecutionContext, Injectable, UnauthorizedException } from '@nestjs/common';
import { AuthGuard } from '@nestjs/passport';
@Injectable()
export class AdminAuthGuard extends AuthGuard('jwt') implements CanActivate {
canActivate(context: ExecutionContext) {
// Add your custom authentication logic here
// for example, call super.logIn(request) to establish a session.
return super.canActivate(context);
}
handleRequest(err, user, info) {
// You can throw an exception based on either "info" or "err" arguments
if (err || !user || !user.roles.includes('ADMIN')) {
throw err || new UnauthorizedException(info);
}
return user;
}
}