Open jerearaujo03 opened 11 months ago
I managed to solve by doing this:
import { ExecutionContext, Injectable } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import { FirebaseAuthGuard } from '@whitecloak/nestjs-passport-firebase';
import { IS_PUBLIC } from './auth.decorator';
@Injectable()
export class CustomFirebaseAuthGuard extends FirebaseAuthGuard {
constructor(private reflector: Reflector) {
super();
}
canActivate(context: ExecutionContext) {
const isPublic = this.reflector.getAllAndOverride<boolean>(IS_PUBLIC, [
context.getHandler(),
context.getClass(),
]);
if (isPublic) {
return true;
}
return super.canActivate(context);
}
}
HI @jerearaujo03, glad you make it work via the custom guard. If you think it would be nice to have such feature, we're happy to accept a PR.
In my
app.module.ts
I have set up a global guard because I want to protect almost all my routes.But the problem is that some routes are public. How can I "bypass" the guard for specific routes? Is there a way to set a specific metadata to avoid the guard?