即使用户已登录,Google 一键登录弹出窗口也会弹出

问题描述 投票:0回答:1

角度16

我想在用户已经登录时阻止/禁用谷歌的一键登录弹出窗口。

每当我刷新或保存代码更改(自动重新加载)时,都会弹出登录弹出窗口,直到我通过单击关闭按钮手动关闭它。

我正在使用 angularx-social-login 包并通过 GoogleSigninButtonModule 按钮和 SocialAuthService 登录用户。

app.module.ts

providers: [
    {
      provide: 'SocialAuthServiceConfig',
      useValue: {
        autoLogin: false,
        providers: [
          {
            id: GoogleLoginProvider.PROVIDER_ID,
            provider: new GoogleLoginProvider(
              myclientid
            )
          }
        ]
      } as SocialAuthServiceConfig,
    }
  ]

app.component.ts

import { SocialAuthService, SocialUser } from '@abacritt/angularx-social-login';

@Component...
export class AppComponent{

constructor(private socialAuthService: SocialAuthService) {
  }

ngOnInit() {
   this.socialAuthService.authState.subscribe({
      next:
        (user: SocialUser) => {
          if (user != null) {
            //My Logic
          }
        },
      error:
        () => {
        }
    })
  }
}

app.component.html

<asl-google-signin-button size='large' class="google-button" type="standard" text="continue_with" width="400"></asl-google-signin-button>
angular google-oauth google-signin google-identity google-one-tap
1个回答
0
投票

我知道这很旧,但我通过将

{ oneTapEnabled: false }
添加到 SocialAuthServiceConfig

来修复此问题
provide: 'SocialAuthServiceConfig',
  useValue: {
    autoLogin: false,
    providers: [{
      id: GoogleLoginProvider.PROVIDER_ID,
      provider: new GoogleLoginProvider('<ID>', { oneTapEnabled: false })
    }]
© www.soinside.com 2019 - 2024. All rights reserved.