Skip to content

Commit d911149

Browse files
committed
Merge branch 'ms4' into ms4-evan/shared-dto
2 parents e7dab55 + b54726b commit d911149

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

backend/gateway-service/src/modules/auth/auth.controller.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,14 @@ export class AuthController {
133133
@Public()
134134
@Get('google/callback')
135135
@ApiOkResponse({ description: 'Google auth callback successful' })
136-
async googleAuthCallback(@Query('code') code: string) {
137-
return await firstValueFrom(
138-
this.authClient.send({ cmd: 'google-auth-redirect' }, { code }),
139-
);
136+
async googleAuthCallback(@Query('code') code: string, @Res() res: Response) {
137+
const { access_token: accessToken, refresh_token: refreshToken } =
138+
await firstValueFrom(
139+
this.authClient.send({ cmd: 'google-auth-redirect' }, { code }),
140+
);
141+
142+
const redirectUrl = `${process.env.FRONTEND_URL}/oauth?accessToken=${accessToken}&refreshToken=${refreshToken}`;
143+
res.redirect(redirectUrl);
140144
}
141145

142146
@Public()
@@ -154,9 +158,13 @@ export class AuthController {
154158
@Public()
155159
@Get('github/callback')
156160
@ApiOkResponse({ description: 'Github auth callback successful' })
157-
async githubAuthCallback(@Query('code') code: string) {
158-
return await firstValueFrom(
159-
this.authClient.send({ cmd: 'github-auth-redirect' }, { code }),
160-
);
161+
async githubAuthCallback(@Query('code') code: string, @Res() res: Response) {
162+
const { access_token: accessToken, refresh_token: refreshToken } =
163+
await firstValueFrom(
164+
this.authClient.send({ cmd: 'github-auth-redirect' }, { code }),
165+
);
166+
167+
const redirectUrl = `${process.env.FRONTEND_URL}/oauth?accessToken=${accessToken}&refreshToken=${refreshToken}`;
168+
res.redirect(redirectUrl);
161169
}
162170
}

0 commit comments

Comments
 (0)