Fix : login redirection
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
SESSION_SECRET=dev
|
||||
|
||||
CLIENT_ENDPOINT=http://localhost:3000
|
||||
API_ENDPOINT=http://localhost:8765
|
||||
DISCORD_CLIENTID=
|
||||
DISCORD_CLIENTSECRET=
|
||||
|
||||
@@ -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<string, any>,
|
||||
): Promise<LoginDto> {
|
||||
): Promise<void> {
|
||||
await this.usersService.createDiscordToken({ code }, session);
|
||||
const user = await this.usersService.discordLogin(session);
|
||||
return user;
|
||||
await this.usersService.discordLogin(session);
|
||||
}
|
||||
|
||||
@Get('/whoami')
|
||||
|
||||
Reference in New Issue
Block a user