diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 46eeeb256266642f9bc35a316fb9becbb2ccfe17..163dc5c2add0af7747609a4b6dbaf64262408474 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -10,17 +10,25 @@ import { EditorialisationModule } from './editorialisation/editorialisation.modu import { Angulartics2Module } from 'angulartics2'; import { UserModule } from './user/user.module'; import { UserService } from './user/services'; -import { AppConfigService } from './core/services'; +import { AppConfigService, NotificationService } from './core/services'; +import { timeout } from 'rxjs/operators'; +import { notificationMessages } from '../i18n/traductions'; // Function used by APP_INITIALIZER before the app start: init user info / statut (expect a promise) -export function initUserService(authService: UserService) { +export function initUserService(authService: UserService, notificationService: NotificationService) { return (): Promise<any> => { return new Promise((resolve, reject) => { - authService.initializeService().subscribe( + authService.initializeService().pipe(timeout(3000)).subscribe( () => { resolve(); }, - () => { + (err) => { + if (err.status !== 401) { + notificationService.notify({ + type: 'error', + message: notificationMessages.userInfo.userInit, + }); + } resolve(); }); }); @@ -61,7 +69,7 @@ export function initAppConfig(appConfigService: AppConfigService) { { provide: APP_INITIALIZER, useFactory: initUserService, - deps: [UserService], + deps: [UserService, NotificationService], multi: true, }, ], diff --git a/src/i18n/traductions.fr.ts b/src/i18n/traductions.fr.ts index 17b49f08b4bd15b8fac0beeef4a917e406017fcb..9b158ebe03ff4188f6cfbb3ae183dc9700f74f99 100644 --- a/src/i18n/traductions.fr.ts +++ b/src/i18n/traductions.fr.ts @@ -68,6 +68,7 @@ export const notificationMessages = { userPasswordUpdated: 'Votre mot de passe a été mis à jour.', wrongOldPassword: 'Il semblerait que l\'ancien mot de passe saisi soit incorrect.', errorDeletingAccount: 'Une erreur est survenue lors de la suppression de votre compte.', + userInit: 'Une erreur est survenue lors de la récupération des informations de votre compte.', }, general: { failedDownloadFile: 'Désolé, il n\'a pas été possible de télécharger le fichier. Essayez plus tard !', diff --git a/src/i18n/traductions.ts b/src/i18n/traductions.ts index 9873793e80df8aec832d22ac1edfa739d352cdb4..307b72d9b26668f375ffd70bd9f51d3ab56780ee 100644 --- a/src/i18n/traductions.ts +++ b/src/i18n/traductions.ts @@ -67,6 +67,7 @@ export const notificationMessages = { failedToUpdateUserPassword: 'An error occured while updating your password.', wrongOldPassword: 'Looks like the old password entered is incorrect.', errorDeletingAccount: 'An error occured while deleting your account.', + userInit: 'An error occured while retrieving your account information.', }, general: { failedDownloadFile: 'Sorry, it was not possible to download the file. Try later !',