abacritt / angularx-social-login

Social login and authentication module for Angular 17
630 stars 388 forks source link

Prevent Google One Tap if user already logged in #661

Closed hheexx closed 1 year ago

hheexx commented 1 year ago

Is there a way to prevent showing google one tap during page load ?

NourasHamwi commented 1 year ago

is there any solution for this scenario ?

NourasHamwi commented 1 year ago

My temporary work around it is this

const googleLoginOptions: GoogleInitOptions = {
  oneTapEnabled: localStorage.getItem('accessToken') ? false : true, // default is true
};
 providers: [
        {
          provide: 'SocialAuthServiceConfig',
          useValue: {
            autoLogin: false,
            providers: [
              {
                id: GoogleLoginProvider.PROVIDER_ID,
                provider: new GoogleLoginProvider(
                  environment.clientId,
                  googleLoginOptions ),                
              }
            ],
            onError: (err) => {
              console.error(err);
            }
          } as SocialAuthServiceConfig,
        },
      ],

This would only work if your login is based on your storage item and named accessToken

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.