-
Notifications
You must be signed in to change notification settings - Fork 0
feat(user): add guards in user update #7
New issue
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
Conversation
|
|
||
| @HttpCode(HttpStatus.OK) | ||
| @Post(':id') | ||
| @UseGuards(UserGuard) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if guard applies not only to this route and applies globally then you can add this above controller decorator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure! thanks!
src/user/user.controller.ts
Outdated
| } | ||
|
|
||
| @HttpCode(HttpStatus.OK) | ||
| @Post(':id') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Post for update ? Shouldn't it be PATCH or PUT
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated!
src/user/user.controller.ts
Outdated
| @HttpCode(HttpStatus.CREATED) | ||
| @Post() | ||
| async createUser(@Body() body: SignupRequestData) { | ||
| return this.UserService.create(body); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if UserService is a class , shouldn't it be instantiated before using it within a constructor ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! The variable name was incorrectly capitalized. I’ve updated it to userService
src/user/user.guards.ts
Outdated
| if (error instanceof Error) { | ||
| throw new UnauthorizedException(error.message); | ||
| } | ||
|
|
||
| throw new UnauthorizedException('Session expired! Please sign in'); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intentional ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes i thought i could handle like that! updated it to just return false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already removed try catch in branch behind
Uh oh!
There was an error while loading. Please reload this page.