abacritt / angularx-social-login

Social login and authentication module for Angular 17
636 stars 387 forks source link

Cannot set properties of null (setting 'provider') #446

Closed bbarn3y closed 2 years ago

bbarn3y commented 3 years ago

I'm getting the following error: image

The relevant code block in angularx-social-login.js:

this.providers.forEach((provider, key) => {
                    let promise = provider.getLoginStatus();
                    loginStatusPromises.push(promise);
                    promise
                        .then((user) => {
                        user.provider = key; // Line 201
                        this._user = user;
                        this._authState.next(user);
                        loggedIn = true;
                    })
                        .catch(console.debug);

The issue started to pop up when I switched to using a factory to configure the module:

export function angularxSocialLoginFactory(): SocialAuthServiceConfig {  
  return {
    autoLogin: true,  
    providers: [  
      {
        id: GoogleLoginProvider.PROVIDER_ID,
        provider: new GoogleLoginProvider(AppService.configSettings.googleApi),
      },
      {
        id: FacebookLoginProvider.PROVIDER_ID,
        provider: new FacebookLoginProvider(AppService.configSettings.facebookApi),
      }
    ]
  };
}
providers: [
   ...
   {
     provide: 'SocialAuthServiceConfig',
     useFactory: angularxSocialLoginFactory
   },
   ...
]

This was a needed change in my case, because the application IDs won't be available in compile-time, the application has to be configured differently in each environment our app runs in and the configuration file is fetched with an HTTP query.

The error itself doesn't seem to cause any issues or at least I haven't noticed yet, I can still log in using Facebook or Google.

Can this exception cause problems, is there a way to get rid of it?

stale[bot] commented 2 years 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.