Open kunalk16 opened 2 years ago
For anyone facing this error, you can handle it in NestJs by adding a filter on top of the controller function:
@Get("linkedin/callback")
@UseGuards(LinkedinAuthGuard)
@UseFilters(new UnauthorizedFilter()) // <--- HERE
linkedinCallback(@LoggedUser() user: User, @Res() res: Response) {
const clientUrl = ".....";
res.redirect(clientUrl);
}
to implement the filter:
@Catch(UnauthorizedException)
export class UnauthorizedFilter implements ExceptionFilter {
catch(exception: HttpException, host: ArgumentsHost) {
const ctx = host.switchToHttp();
const response = ctx.getResponse<Response>();
// Get the error message from the exception if available
const errorMessage = exception?.message || "Unauthorized";
// Do something with the error
response.redirect(CLIENT_URL);
}
}
Please do not report security vulnerabilities here. The Responsible Disclosure Program details the procedure for disclosing security issues.
Thank you in advance for helping us to improve this library! Please read through the template below and answer all relevant questions. Your additional work here is greatly appreciated and will help us respond as quickly as possible. For general support or usage questions, use the Auth0 Community or Auth0 Support. Finally, to avoid duplicates, please search existing Issues before submitting one here.
By submitting an Issue to this repository, you agree to the terms within the Auth0 Code of Conduct.
Description
Reproduction
Environment
Strategy code: