Fix : login redirection
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
SESSION_SECRET=dev
|
SESSION_SECRET=dev
|
||||||
|
|
||||||
|
CLIENT_ENDPOINT=http://localhost:3000
|
||||||
API_ENDPOINT=http://localhost:8765
|
API_ENDPOINT=http://localhost:8765
|
||||||
DISCORD_CLIENTID=
|
DISCORD_CLIENTID=
|
||||||
DISCORD_CLIENTSECRET=
|
DISCORD_CLIENTSECRET=
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {
|
|||||||
Session,
|
Session,
|
||||||
HttpException,
|
HttpException,
|
||||||
HttpStatus,
|
HttpStatus,
|
||||||
|
Redirect,
|
||||||
} from '@nestjs/common';
|
} from '@nestjs/common';
|
||||||
import { UsersService } from './users.service';
|
import { UsersService } from './users.service';
|
||||||
import { LoginDto } from './dto/login.dto';
|
import { LoginDto } from './dto/login.dto';
|
||||||
@@ -16,13 +17,13 @@ export class UsersController {
|
|||||||
constructor(private readonly usersService: UsersService) {}
|
constructor(private readonly usersService: UsersService) {}
|
||||||
|
|
||||||
@Get('/login')
|
@Get('/login')
|
||||||
|
@Redirect(process.env.CLIENT_ENDPOINT)
|
||||||
async login(
|
async login(
|
||||||
@Query('code') code: string,
|
@Query('code') code: string,
|
||||||
@Session() session: Record<string, any>,
|
@Session() session: Record<string, any>,
|
||||||
): Promise<LoginDto> {
|
): Promise<void> {
|
||||||
await this.usersService.createDiscordToken({ code }, session);
|
await this.usersService.createDiscordToken({ code }, session);
|
||||||
const user = await this.usersService.discordLogin(session);
|
await this.usersService.discordLogin(session);
|
||||||
return user;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Get('/whoami')
|
@Get('/whoami')
|
||||||
|
|||||||
Reference in New Issue
Block a user