Skip to content

Commit

Permalink
fix(dev): swagger description and discord log
Browse files Browse the repository at this point in the history
  • Loading branch information
ewen1507 committed Jan 19, 2025
1 parent 36c2b1d commit cfa3bbf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
13 changes: 0 additions & 13 deletions src/server/src/app-discord/discord-app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,6 @@ export class DiscordService {
throw new BadRequestException('Code or userId is missing');
}

console.log(
'DISCORD_CLIENT_ID:',
this.configService.get<string>('DISCORD_CLIENT_ID'),
);
console.log(
'DISCORD_CLIENT_SECRET:',
this.configService.get<string>('DISCORD_CLIENT_SECRET'),
);
console.log(
'IP_REDIRECT:',
`${this.configService.get<string>('IP_REDIRECT')}auth/discord/callback`,
);

const tokens = await this.exchangeCodeForTokens(
code,
this.configService.get<string>('DISCORD_CLIENT_ID'),
Expand Down
28 changes: 27 additions & 1 deletion src/server/src/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ export class AuthController {
}

@Get('google/redirect/:service')
@ApiOperation({ summary: 'Redirect to Google OAuth' })
@ApiResponse({ status: 200, description: 'Redirect URL' })
@ApiResponse({ status: 400, description: 'Bad Request' })
async googleAuthRedirect(@Param('service') service: string) {
if (service !== 'gcalendar') {
return;
Expand All @@ -160,6 +163,9 @@ export class AuthController {
}

@Post('google/callback/:service')
@ApiOperation({ summary: 'Google OAuth callback' })
@ApiResponse({ status: 200, description: 'Tokens stored in the database' })
@ApiResponse({ status: 400, description: 'Bad Request' })
@UseGuards(AuthGuard('jwt'))
async googleAuthCallback(
@Param('service') service: string,
Expand All @@ -175,13 +181,17 @@ export class AuthController {
}

@Get('discord/redirect')
@ApiOperation({ summary: 'Redirect to Discord OAuth' })
@ApiResponse({ status: 200, description: 'Redirect URL' })
@ApiResponse({ status: 400, description: 'Bad Request' })
async discordAuthRedirect(@Req() req) {
console.log('Redirecting to Discord OAuth');
const redirectUrl = await this.discordService.getRedirectUrl();
return { redirectUrl };
}

//retourne le dans le body le lien de redirection
//@Get('discord')
@Get('discord')
async discordAuth() {
const redirectUrl = await this.discordService.getRedirectUrl();
console.log('Redirecting to Discord OAuth:', redirectUrl);
Expand Down Expand Up @@ -315,6 +325,9 @@ export class AuthController {
}

@Post('discord')
@ApiOperation({ summary: 'Discord OAuth, route for receive code from discord' })
@ApiResponse({status: 200, description: 'Tokens stored in the database'})
@ApiResponse({status: 400, description: 'Bad Request'})
async discordOAuth(@Body('code') code: string) {
if (!code) {
throw new BadRequestException('Code is missing');
Expand All @@ -329,12 +342,18 @@ export class AuthController {
}

@Get('spotify/redirect')
@ApiOperation({ summary: 'Redirect to Spotify OAuth' })
@ApiResponse({ status: 200, description: 'Redirect URL' })
@ApiResponse({ status: 400, description: 'Bad Request' })
spotifyAuthRedirect(): { redirectUrl: string } {
const redirectUrl = this.spotifyAuthService.generateAuthUrl();
return { redirectUrl };
}

@Post('spotify/callback')
@ApiOperation({ summary: 'Spotify OAuth callback' })
@ApiResponse({ status: 200, description: 'Tokens stored in the database' })
@ApiResponse({ status: 400, description: 'Bad Request' })
@UseGuards(AuthGuard('jwt'))
async getSpotifyCallback(@Body('code') code: string, @Req() req: any) {
if (!code) {
Expand All @@ -355,6 +374,10 @@ export class AuthController {
});
}
}

@ApiOperation({ summary: 'Redirect to Twitch OAuth' })
@ApiResponse({ status: 200, description: 'Redirect URL' })
@ApiResponse({ status: 400, description: 'Bad Request' })
@Get('twitch/redirect')
twitchAuthRedirect(): { redirectUrl: string } {
// Génère l’URL d’authentification Twitch
Expand All @@ -364,6 +387,9 @@ export class AuthController {
}

@Post('twitch/callback')
@ApiOperation({ summary: 'Twitch OAuth callback' })
@ApiResponse({ status: 200, description: 'Tokens stored in the database' })
@ApiResponse({ status: 400, description: 'Bad Request' })
@UseGuards(AuthGuard('jwt'))
async getTwitchCallback(@Body('code') code: string, @Req() req: any) {
console.log('Twitch OAuth callback received:', code);
Expand Down

0 comments on commit cfa3bbf

Please sign in to comment.