Since LoginProvider & BaseLoginProvider are exported from the lib, as consumers we can implement our own login providers.
That's good but we seem forced to create our login provider instances directly when we provide a value for SocialAuthServiceConfig, and we have no easy way to inject other services in our custom login providers.
This PR should make something like this possible
@Injectable({ providedIn: 'root' })
export class MyCustomLoginProvider extends BaseLoginProvider {
public static readonly PROVIDER_ID = 'CUSTOM' as const;
constructor(/* infinite list of dependencies*/) {}
}
...
@NgModule({
declarations: [AppComponent, NavbarComponent, DemoComponent],
imports: [BrowserModule, FormsModule, SocialLoginModule],
providers: [
{
provide: 'SocialAuthServiceConfig',
useValue: {
autoLogin: true,
providers: [
{
id: MyCustomLoginProvider.PROVIDER_ID,
provider: MyCustomLoginProvider,
},
],
} as SocialAuthServiceConfig,
},
],
MyCustomLoginProvider would then be a real angular provider.
A change was made also on getLoginStatus(refreshToken?: boolean): Promise<SocialUser> signature, it was splitted into getLoginStatus(): Promise<SocialUser> & refreshToken?(): Promise<SocialUser | null>.
The refreshToken?: boolean parameter was only used by GoogleLoginProvider, and passing true to it was doing something really different of passing false.
With that new optional refreshToken() method that providers can implement, we just need to check for the presence of a refreshToken function in SocialAuthService.refreshAuthToken()
signIn() method abstract again in BaseLoginProvider, GoogleLoginProvider implements it again but rejects with a message saying it is no longer supported, with a link to Google doc.
Since LoginProvider & BaseLoginProvider are exported from the lib, as consumers we can implement our own login providers. That's good but we seem forced to create our login provider instances directly when we provide a value for
SocialAuthServiceConfig
, and we have no easy way to inject other services in our custom login providers.This PR should make something like this possible
MyCustomLoginProvider
would then be a real angular provider.A change was made also on
getLoginStatus(refreshToken?: boolean): Promise<SocialUser>
signature, it was splitted intogetLoginStatus(): Promise<SocialUser>
&refreshToken?(): Promise<SocialUser | null>
. TherefreshToken?: boolean
parameter was only used by GoogleLoginProvider, and passing true to it was doing something really different of passing false.With that new optional refreshToken() method that providers can implement, we just need to check for the presence of a refreshToken function in
SocialAuthService.refreshAuthToken()
signIn()
method abstract again inBaseLoginProvider
,GoogleLoginProvider
implements it again but rejects with a message saying it is no longer supported, with a link to Google doc.