Make google auth optional on server side (#508)
* Make google auth optional on server side * fix lint * Fix according to review
This commit is contained in:
@ -11,6 +11,7 @@ import { Response } from 'express';
|
||||
import { GoogleRequest } from '../strategies/google.auth.strategy';
|
||||
import { UserService } from '../../user/user.service';
|
||||
import { TokenService } from '../services/token.service';
|
||||
import { GoogleProviderEnabledGuard } from '../guards/google-provider-enabled.guard';
|
||||
|
||||
@Controller('auth/google')
|
||||
export class GoogleAuthController {
|
||||
@ -20,14 +21,14 @@ export class GoogleAuthController {
|
||||
) {}
|
||||
|
||||
@Get()
|
||||
@UseGuards(AuthGuard('google'))
|
||||
@UseGuards(GoogleProviderEnabledGuard, AuthGuard('google'))
|
||||
async googleAuth() {
|
||||
// As this method is protected by Google Auth guard, it will trigger Google SSO flow
|
||||
return;
|
||||
}
|
||||
|
||||
@Get('redirect')
|
||||
@UseGuards(AuthGuard('google'))
|
||||
@UseGuards(GoogleProviderEnabledGuard, AuthGuard('google'))
|
||||
async googleAuthRedirect(@Req() req: GoogleRequest, @Res() res: Response) {
|
||||
const { firstName, lastName, email } = req.user;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user