Refactor client config (#529)
* Refactor client config * Fix server tests * Fix lint
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { Args, Mutation, Resolver, Query } from '@nestjs/graphql';
|
||||
import { AuthTokens, ClientConfig } from './dto/token.entity';
|
||||
import { AuthTokens } from './dto/token.entity';
|
||||
import { TokenService } from './services/token.service';
|
||||
import { RefreshTokenInput } from './dto/refresh-token.input';
|
||||
import { BadRequestException } from '@nestjs/common';
|
||||
@ -61,17 +61,4 @@ export class AuthResolver {
|
||||
|
||||
return { tokens: tokens };
|
||||
}
|
||||
|
||||
@Query(() => ClientConfig)
|
||||
async clientConfig(): Promise<ClientConfig> {
|
||||
const displayGoogleLogin = process.env.AUTH_GOOGLE_CLIENT_ID !== undefined;
|
||||
const prefillLoginWithSeed = process.env.NODE_ENV === 'development';
|
||||
|
||||
const clientConfig: ClientConfig = {
|
||||
display_google_login: displayGoogleLogin,
|
||||
prefill_login_with_seed: prefillLoginWithSeed,
|
||||
};
|
||||
|
||||
return Promise.resolve(clientConfig);
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,12 +23,3 @@ export class AuthTokens {
|
||||
@Field(() => AuthTokenPair)
|
||||
tokens: AuthTokenPair;
|
||||
}
|
||||
|
||||
@ObjectType()
|
||||
export class ClientConfig {
|
||||
@Field(() => Boolean)
|
||||
display_google_login: boolean;
|
||||
|
||||
@Field(() => Boolean)
|
||||
prefill_login_with_seed: boolean;
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ import { GoogleStrategy } from '../strategies/google.auth.strategy';
|
||||
export class GoogleProviderEnabledGuard implements CanActivate {
|
||||
constructor(private readonly environmentService: EnvironmentService) {}
|
||||
canActivate(): boolean | Promise<boolean> | Observable<boolean> {
|
||||
if (!this.environmentService.getAuthGoogleEnabled()) {
|
||||
if (!this.environmentService.isAuthGoogleEnabled()) {
|
||||
throw new NotFoundException('Google auth is not enabled');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user