diff --git a/src/app/core/auth/auth.service.ts b/src/app/core/auth/auth.service.ts index 7d854d9d4de..a0e33fc40c9 100644 --- a/src/app/core/auth/auth.service.ts +++ b/src/app/core/auth/auth.service.ts @@ -21,8 +21,8 @@ import { getAuthenticationToken, getRedirectUrl, isAuthenticated, - isTokenRefreshing, - isAuthenticatedLoaded + isAuthenticatedLoaded, + isTokenRefreshing } from './selectors'; import { AppState, routerStateSelector } from '../../app.reducer'; import { @@ -34,7 +34,7 @@ import { NativeWindowRef, NativeWindowService } from '../services/window.service import { Base64EncodeUrl } from '../../shared/utils/encode-decode.util'; import { RouteService } from '../services/route.service'; import { EPersonDataService } from '../eperson/eperson-data.service'; -import { getAllSucceededRemoteDataPayload } from '../shared/operators'; +import { getAllSucceededRemoteDataPayload, getFinishedRemoteData, getRemoteDataPayload } from '../shared/operators'; import { AuthMethod } from './models/auth.method'; export const LOGIN_ROUTE = '/login'; @@ -206,8 +206,9 @@ export class AuthService { return this.store.pipe( select(getAuthenticatedUserId), hasValueOperator(), - switchMap((id: string) => this.epersonService.findById(id) ), - getAllSucceededRemoteDataPayload() + switchMap((id: string) => this.epersonService.findById(id)), + getFinishedRemoteData(), + getRemoteDataPayload(), ) } diff --git a/src/app/core/locale/locale.service.ts b/src/app/core/locale/locale.service.ts index b7f9314a337..3fc637ff3bf 100644 --- a/src/app/core/locale/locale.service.ts +++ b/src/app/core/locale/locale.service.ts @@ -1,4 +1,4 @@ -import { Injectable, Inject } from '@angular/core'; +import { Inject, Injectable } from '@angular/core'; import { TranslateService } from '@ngx-translate/core'; @@ -6,9 +6,9 @@ import { isEmpty, isNotEmpty } from '../../shared/empty.util'; import { CookieService } from '../services/cookie.service'; import { environment } from '../../../environments/environment'; import { AuthService } from '../auth/auth.service'; -import { Observable, of as observableOf, combineLatest } from 'rxjs'; -import { map, take, flatMap } from 'rxjs/operators'; -import { NativeWindowService, NativeWindowRef } from '../services/window.service'; +import { combineLatest, Observable, of as observableOf } from 'rxjs'; +import { flatMap, map, take } from 'rxjs/operators'; +import { NativeWindowRef, NativeWindowService } from '../services/window.service'; export const LANG_COOKIE = 'language_cookie'; @@ -19,7 +19,7 @@ export enum LANG_ORIGIN { UI, EPERSON, BROWSER -}; +} /** * Service to provide localization handler @@ -81,12 +81,14 @@ export class LocaleService { take(1), map((eperson) => { const languages: string[] = []; - const ePersonLang = eperson.firstMetadataValue(this.EPERSON_LANG_METADATA); - if (ePersonLang) { - languages.push(...this.setQuality( - [ePersonLang], - LANG_ORIGIN.EPERSON, - !isEmpty(this.translate.currentLang))); + if (eperson) { + const ePersonLang = eperson.firstMetadataValue(this.EPERSON_LANG_METADATA); + if (ePersonLang) { + languages.push(...this.setQuality( + [ePersonLang], + LANG_ORIGIN.EPERSON, + !isEmpty(this.translate.currentLang))); + } } return languages; })