We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I want to get user info from jwt token in controller , like this:
@Get('getUser') getUser(@User() user) { return user; }
so I create a custom param decorator like this:
export const User = createParamDecorator((data: string, ctx: ExecutionContext) => { const request = ctx.switchToHttp().getRequest<Request>(); const arr = request.headers.authorization?.split(' ') ?? []; const token = arr.at(-1); if (!token) { return undefined; } // how to inject jwtService ? const payload = jwtService.verify(token); return payload; });
how to inject jwtService into the decorator ? thanks !
The text was updated successfully, but these errors were encountered:
Have you found a solution now having the same problem with my custom decorator.
Sorry, something went wrong.
This has nothing to do with the awesome-nestjs repository
Try the following instead:
nestjs
No branches or pull requests
I want to get user info from jwt token in controller , like this:
so I create a custom param decorator like this:
how to inject jwtService into the decorator ? thanks !
The text was updated successfully, but these errors were encountered: