(
@GetUserIdFromToken() userId: string,
@Args('file', { type: () => GraphQLUpload }) file: Promise<FileUpload>,
)
| 94 | @Query(() => User) |
| 95 | @UseGuards(JWTAuthGuard) |
| 96 | async me(@GetUserIdFromToken() id: string): Promise<User> { |
| 97 | Logger.log('me id:', id); |
| 98 | return this.userService.getUser(id); |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Role names for the caller, so the client can offer the operator console to |
| 103 | * the people who can actually open it. Names rather than the Role entity: |
| 104 | * the GraphQL type `Role` is already the message-author enum. |
| 105 | * |
| 106 | * A top-level guarded query rather than a field on User. As a @ResolveField |
| 107 | * it ran with no guard at all — APP_GUARD does not reach field resolvers |
| 108 | * unless `fieldResolverEnhancers` is set, and it is not — so anonymous |
| 109 | * callers could walk fetchPublicProjects (@Public) → Project.user → roles |
| 110 | * and enumerate which accounts are admins. Asking only about the bearer |
| 111 | * means there is no other user's roles to leak. |
| 112 | */ |
| 113 | @Query(() => [String]) |
| 114 | @UseGuards(JWTAuthGuard) |
| 115 | async myRoles(@GetUserIdFromToken() id: string): Promise<string[]> { |
| 116 | const { roles } = await this.authService.getUserRoles(id); |
| 117 | return roles.map((role) => role.name); |
| 118 | } |
| 119 | |
| 120 | /** Rename yourself. The settings page called this "not editable yet". */ |
nothing calls this directly
no test coverage detected