check for available providers even earlier

This commit is contained in:
Jacob Overgaard
2024-04-16 11:56:06 +02:00
parent 34379e46b6
commit 02cbfb8075

View File

@@ -74,6 +74,10 @@ export class UmbAppAuthController extends UmbControllerBase {
// Figure out which providers are available
const availableProviders = await firstValueFrom(this.#authContext.getAuthProviders());
if (availableProviders.length === 0) {
throw new Error('[Fatal] No auth providers available');
}
// If the user is timed out, we can show the login modal directly
if (userLoginState === 'timedOut') {
const selected = await this.#showLoginModal(userLoginState, availableProviders);
@@ -85,10 +89,6 @@ export class UmbAppAuthController extends UmbControllerBase {
return this.#updateState();
}
if (availableProviders.length === 0) {
throw new Error('[Fatal] No auth providers available');
}
if (availableProviders.length === 1) {
// One provider available (most likely the Umbraco provider), so initiate the authorization request to the default provider
this.#authContext.makeAuthorizationRequest(availableProviders[0].forProviderName);