How to handle a route that authentication is optional?
seekcx opened this issue · comments
abel commented
I'd like to create routes that authenticates req.user for authenticated users but still allow non authenticated users to access the route.
Would anybody be as kind to give me a workaround?
Kamil Mysliwiec commented
You can simply extend AuthGuard
and return true
even if canActivate
either throws an exception/returns false. :)
Vitalii Kryvenko commented
@kamilmysliwiec Could you please attach passport info
object to the exception that you throw, because I need to know why the exception was actually thrown.