Skip to content

Commit 354d2ab

Browse files
Add initialization check for signing
If the initialization is not complete when trying to sign in, the response from the identity-provider will be "lost" because no `Notifier` is registered with the @openid/appauth code. This will lead to an infinite wait for the result of the login. That is quite time-consuming to debug. Therefore, an error should make things a lot easier for the programmer.
1 parent 1c2bfa2 commit 354d2ab

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/auth-service.ts

+4
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,10 @@ export class AuthService implements IAuthService {
342342
}
343343

344344
public async signIn(authExtras?: StringMap, state?: string) {
345+
if (!this._initComplete.value) {
346+
throw new Error('Trying to sign in before AuthService is initialized!');
347+
}
348+
345349
await this.performAuthorizationRequest(authExtras, state).catch((response) => {
346350
this.notifyActionListers(AuthActionBuilder.SignInFailed(response));
347351
});

0 commit comments

Comments
 (0)