diff --git a/.env.dev b/.env.dev index ca63f61..446aaa3 100644 --- a/.env.dev +++ b/.env.dev @@ -1,5 +1,6 @@ SESSION_SECRET=dev +CLIENT_ENDPOINT=http://localhost:3000 API_ENDPOINT=http://localhost:8765 DISCORD_CLIENTID= DISCORD_CLIENTSECRET= diff --git a/src/users/users.controller.ts b/src/users/users.controller.ts index a713782..3b63209 100644 --- a/src/users/users.controller.ts +++ b/src/users/users.controller.ts @@ -5,6 +5,7 @@ import { Session, HttpException, HttpStatus, + Redirect, } from '@nestjs/common'; import { UsersService } from './users.service'; import { LoginDto } from './dto/login.dto'; @@ -16,13 +17,13 @@ export class UsersController { constructor(private readonly usersService: UsersService) {} @Get('/login') + @Redirect(process.env.CLIENT_ENDPOINT) async login( @Query('code') code: string, @Session() session: Record, - ): Promise { + ): Promise { await this.usersService.createDiscordToken({ code }, session); - const user = await this.usersService.discordLogin(session); - return user; + await this.usersService.discordLogin(session); } @Get('/whoami')