| ... | @@ -76,7 +76,7 @@ It's also possible to define functions, which can be called from services. An ex |
... | @@ -76,7 +76,7 @@ It's also possible to define functions, which can be called from services. An ex |
|
|
|
|
|
|
|
The AuthGuard located in shared folder verifies the user's token. If the validation passes, it splits the token and stores the information from the token to the request object. This way, the data can be accessed in services. User decorator is mainly used to get the user's UUID. The decorator is called in controllers, which passes it to the services.
|
|
The AuthGuard located in shared folder verifies the user's token. If the validation passes, it splits the token and stores the information from the token to the request object. This way, the data can be accessed in services. User decorator is mainly used to get the user's UUID. The decorator is called in controllers, which passes it to the services.
|
|
|
|
|
|
|
|
```
|
|
```typescript
|
|
|
@Post('example')
|
|
@Post('example')
|
|
|
@UseGuards(new AuthGuard())
|
|
@UseGuards(new AuthGuard())
|
|
|
async newGame(@User('id') userId, @Body() data) {
|
|
async newGame(@User('id') userId, @Body() data) {
|
| ... | @@ -84,4 +84,4 @@ The AuthGuard located in shared folder verifies the user's token. If the validat |
... | @@ -84,4 +84,4 @@ The AuthGuard located in shared folder verifies the user's token. If the validat |
|
|
}
|
|
}
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
**Routes using the `@User` decorator MUST use the AuthGuard decorator!** |
|
**Routes using the `@User` decorator MUST also use the AuthGuard decorator!** |