diff --git a/src/app/core/auth/auth.service.ts b/src/app/core/auth/auth.service.ts index 109002a776..3f51499421 100644 --- a/src/app/core/auth/auth.service.ts +++ b/src/app/core/auth/auth.service.ts @@ -11,6 +11,7 @@ import { } from '@ngrx/store'; import { TranslateService } from '@ngx-translate/core'; import { CookieAttributes } from 'js-cookie'; +import uniqBy from 'lodash/uniqBy'; import { Observable, of as observableOf, @@ -38,6 +39,7 @@ import { isNotNull, isNotUndefined, } from '../../shared/empty.util'; +import { rendersAuthMethodType } from '../../shared/log-in/methods/log-in.methods-decorator'; import { NotificationsService } from '../../shared/notifications/notifications.service'; import { createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; import { followLink } from '../../shared/utils/follow-link-config.model'; @@ -74,6 +76,7 @@ import { } from './auth.actions'; import { AuthRequestService } from './auth-request.service'; import { AuthMethod } from './models/auth.method'; +import { AuthMethodType } from './models/auth.method-type'; import { AuthStatus } from './models/auth-status.model'; import { AuthTokenInfo, @@ -81,6 +84,7 @@ import { } from './models/auth-token-info.model'; import { getAuthenticatedUserId, + getAuthenticationMethods, getAuthenticationToken, getExternalAuthCookieStatus, getRedirectUrl, @@ -690,4 +694,18 @@ export class AuthService { } } + public getAuthMethods(excludedAuthMethod?: AuthMethodType): Observable { + return this.store.pipe( + select(getAuthenticationMethods), + map((methods: AuthMethod[]) => methods + // ignore the given auth method if it should be excluded + .filter((authMethod: AuthMethod) => excludedAuthMethod == null || authMethod.authMethodType !== excludedAuthMethod) + .filter((authMethod: AuthMethod) => rendersAuthMethodType(authMethod.authMethodType) !== undefined) + .sort((method1: AuthMethod, method2: AuthMethod) => method1.position - method2.position), + ), + // ignore the ip authentication method when it's returned by the backend + map((authMethods: AuthMethod[]) => uniqBy(authMethods.filter(a => a.authMethodType !== AuthMethodType.Ip), 'authMethodType')), + ); + } + } diff --git a/src/app/external-log-in/email-confirmation/confirm-email/confirm-email.component.html b/src/app/external-log-in/email-confirmation/confirm-email/confirm-email.component.html index 12aade4bcd..98ef01da29 100644 --- a/src/app/external-log-in/email-confirmation/confirm-email/confirm-email.component.html +++ b/src/app/external-log-in/email-confirmation/confirm-email/confirm-email.component.html @@ -1,29 +1,37 @@ -

+

{{ "external-login.confirm-email.header" | translate }}

- - @if (emailForm.get('email').hasError('required') && emailForm.get('email').touched) { -
- {{ "external-login.confirmation.email-required" | translate }} +
+
+ + @if (emailForm.get('email').hasError('required') && emailForm.get('email').touched) { +
+ {{ "external-login.confirmation.email-required" | translate }} +
+ } + @if (emailForm.get('email').hasError('email') && emailForm.get('email').touched) { +
+ {{ "external-login.confirmation.email-invalid" | translate }} +
+ }
- } - @if (emailForm.get('email').hasError('email') && emailForm.get('email').touched) { -
- {{ "external-login.confirmation.email-invalid" | translate }} +
+
+
+
- } +
- diff --git a/src/app/external-log-in/email-confirmation/provide-email/provide-email.component.html b/src/app/external-log-in/email-confirmation/provide-email/provide-email.component.html index e135b40b4b..1b89ab54b6 100644 --- a/src/app/external-log-in/email-confirmation/provide-email/provide-email.component.html +++ b/src/app/external-log-in/email-confirmation/provide-email/provide-email.component.html @@ -1,30 +1,37 @@ -

+

{{ "external-login.provide-email.header" | translate }}

- +
+
+ - @if (emailForm.get('email').hasError('required') && emailForm.get('email').touched) { -
- {{ "external-login.confirmation.email-required" | translate }} + @if (emailForm.get('email').hasError('required') && emailForm.get('email').touched) { +
+ {{ "external-login.confirmation.email-required" | translate }} +
+ } + @if (emailForm.get('email').hasError('email') && emailForm.get('email').touched) { +
+ {{ "external-login.confirmation.email-invalid" | translate }} +
+ }
- } - @if (emailForm.get('email').hasError('email') && emailForm.get('email').touched) { -
- {{ "external-login.confirmation.email-invalid" | translate }} +
+
+
+
- } +
- - diff --git a/src/app/external-log-in/external-log-in/external-log-in.component.html b/src/app/external-log-in/external-log-in/external-log-in.component.html index c41570927a..cdcc89e6d9 100644 --- a/src/app/external-log-in/external-log-in/external-log-in.component.html +++ b/src/app/external-log-in/external-log-in/external-log-in.component.html @@ -1,34 +1,38 @@
-

{{ 'external-login.confirmation.header' | translate}}

+

{{ 'external-login.confirmation.header' | translate }}

- + {{ informationText }} -
-
- @if (registrationData.email) { - - } @else { +
+
+
+ @if (registrationData.email) { + + } @else { } -
-
-

{{ 'external-login.component.or' | translate }}

-
-
- +
+ @if (hasAuthMethodTypes | async) { +
+

{{ 'external-login.component.or' | translate }}

+
+
+ +
+ }