Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
aglinxinyuan committed Jan 18, 2025
1 parent 819e5ef commit bf3fe28
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ class GoogleAuthResource {

@GET
@Path("/clientid")
@Produces(Array(MediaType.APPLICATION_JSON))
def getClientId: Map[String, String] = {
Map("clientId" -> clientId)
}
def getClientId: String = clientId

@POST
@Consumes(Array(MediaType.TEXT_PLAIN))
Expand Down
22 changes: 10 additions & 12 deletions core/gui/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,6 @@ import { lastValueFrom } from "rxjs";

registerLocaleData(en);

const socialConfigFactory = (googleAuthService: GoogleAuthService, userService: UserService) => {
return lastValueFrom(googleAuthService.getClientId()).then(response => ({
providers: [
{
id: GoogleLoginProvider.PROVIDER_ID,
provider: new GoogleLoginProvider(response?.clientId || "", {oneTapEnabled: !userService.isLogin()}),
},
]
})) as Promise<SocialAuthServiceConfig>;
};

@NgModule({
declarations: [
AdminGmailComponent,
Expand Down Expand Up @@ -320,7 +309,16 @@ const socialConfigFactory = (googleAuthService: GoogleAuthService, userService:
},
{
provide: "SocialAuthServiceConfig",
useFactory: socialConfigFactory,
useFactory: (googleAuthService: GoogleAuthService, userService: UserService) => {
return lastValueFrom(googleAuthService.getClientId()).then(clientId => ({
providers: [
{
id: GoogleLoginProvider.PROVIDER_ID,
provider: new GoogleLoginProvider(clientId, {oneTapEnabled: !userService.isLogin()}),
},
]
})) as Promise<SocialAuthServiceConfig>;
},
deps: [GoogleAuthService, UserService],
},
],
Expand Down
4 changes: 2 additions & 2 deletions core/gui/src/app/common/service/user/google-auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { AppSettings } from "../../app-setting";
export class GoogleAuthService {
constructor(private http: HttpClient) {}

getClientId(): Observable<{ clientId: string }> {
return this.http.get<{ clientId: string }>(`${AppSettings.getApiEndpoint()}/auth/google/clientid`);
getClientId(): Observable<string> {
return this.http.get(`${AppSettings.getApiEndpoint()}/auth/google/clientid`, { responseType: "text" })
}
}

0 comments on commit bf3fe28

Please sign in to comment.