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:
14
server/src/core/auth/guards/google-provider-enabled.guard.ts
Normal file
14
server/src/core/auth/guards/google-provider-enabled.guard.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import { Injectable, CanActivate, HttpException } from '@nestjs/common';
|
||||
import { Observable } from 'rxjs';
|
||||
import { EnvironmentService } from 'src/integrations/environment/environment.service';
|
||||
|
||||
@Injectable()
|
||||
export class GoogleProviderEnabledGuard implements CanActivate {
|
||||
constructor(private readonly environmentService: EnvironmentService) {}
|
||||
canActivate(): boolean | Promise<boolean> | Observable<boolean> {
|
||||
if (!this.environmentService.getAuthGoogleEnabled()) {
|
||||
throw new HttpException('Google auth is not enabled', 404);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user