diff --git a/backend/src/auth/auth.controller.ts b/backend/src/auth/auth.controller.ts index 1ed515f..0ce6a8f 100644 --- a/backend/src/auth/auth.controller.ts +++ b/backend/src/auth/auth.controller.ts @@ -1,4 +1,4 @@ -import { Controller, Post, Body } from '@nestjs/common'; +import { Controller, Post, Body, Get, Req } from '@nestjs/common'; import { AuthService } from './auth.service'; import { CreateAuthDto } from './dto/create-auth.dto'; import { ApiTags } from '@nestjs/swagger'; @@ -14,4 +14,10 @@ export class AuthController { create(@Body() createAuthDto: CreateAuthDto) { return this.authService.createOrLogin(createAuthDto); } + + @Get() + getAuth(@Req() req) { + const userId = req.user.sub; + return this.authService.getAuthUser(userId); + } } diff --git a/backend/src/auth/auth.service.ts b/backend/src/auth/auth.service.ts index 12292cc..e3d6f78 100644 --- a/backend/src/auth/auth.service.ts +++ b/backend/src/auth/auth.service.ts @@ -59,6 +59,10 @@ export class AuthService { }; } + async getAuthUser(id: string) { + return this.usersService.findOne(id); + } + // Function to validate signature private async isValidSignature( address: string, diff --git a/backend/src/common/guards/auth.guard.ts b/backend/src/common/guards/auth.guard.ts index 2c42a5e..0e3bb5b 100644 --- a/backend/src/common/guards/auth.guard.ts +++ b/backend/src/common/guards/auth.guard.ts @@ -15,7 +15,7 @@ export class AuthGuard implements CanActivate { constructor( private jwtService: JwtService, private reflector: Reflector, - ) { } + ) {} async canActivate(context: ExecutionContext): Promise { const isPublic = this.reflector.getAllAndOverride(IS_PUBLIC_KEY, [ diff --git a/backend/src/main.ts b/backend/src/main.ts index 54b2c9a..f71bacf 100644 --- a/backend/src/main.ts +++ b/backend/src/main.ts @@ -25,7 +25,7 @@ async function bootstrap() { const document = SwaggerModule.createDocument(app, config); SwaggerModule.setup('swagger/api', app, document); - app.enableCors(); + app.enableCors({}); await app.listen(PORT, () => { console.log(`Running API in MODE: ${process.env.NODE_ENV} on port ${PORT}`); }); diff --git a/backend/src/users/users.controller.ts b/backend/src/users/users.controller.ts index 3299fed..bf7dd89 100644 --- a/backend/src/users/users.controller.ts +++ b/backend/src/users/users.controller.ts @@ -43,6 +43,11 @@ export class UsersController { return this.usersService.findOne(id); } + @Get(':address') + findByAddress(@Param('address') address: string) { + return this.usersService.findOneByAddress(address); + } + @Delete(':id') remove(@Param('id') id: string) { return this.usersService.remove(+id);