From c8d5b5b42980aada75b0291c3c3ac4b6db86c034 Mon Sep 17 00:00:00 2001 From: isra el Date: Tue, 16 May 2023 10:12:23 +0300 Subject: [PATCH] feat(api): add an endpoint to check the current logged in user --- api/src/auth/auth.controller.ts | 13 +++++++++++++ api/src/gateway/gateway.dto.ts | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/api/src/auth/auth.controller.ts b/api/src/auth/auth.controller.ts index 0f21a41..1803ed7 100644 --- a/api/src/auth/auth.controller.ts +++ b/api/src/auth/auth.controller.ts @@ -42,6 +42,19 @@ export class AuthController { return { data } } + @ApiOperation({ summary: 'Get current logged in user' }) + @ApiQuery({ + name: 'apiKey', + required: false, + description: 'Required if jwt bearer token not provided', + }) + @ApiBearerAuth() + @UseGuards(AuthGuard) + @Get('/who-am-i') + async whoAmI(@Request() req) { + return { data: req.user } + } + @UseGuards(AuthGuard) @ApiOperation({ summary: 'Generate Api Key' }) @ApiQuery({ diff --git a/api/src/gateway/gateway.dto.ts b/api/src/gateway/gateway.dto.ts index 4881f81..07baf66 100644 --- a/api/src/gateway/gateway.dto.ts +++ b/api/src/gateway/gateway.dto.ts @@ -35,7 +35,7 @@ export class RegisterDeviceInputDTO { appVersionCode?: number } -export class ISMSData { +export class SMSData { @ApiProperty({ type: String, required: true, @@ -51,4 +51,4 @@ export class ISMSData { }) receivers: string[] } -export class SendSMSInputDTO extends ISMSData {} +export class SendSMSInputDTO extends SMSData {}