Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
web-et-numerique
web-et-numerique-internet
data.grandlyon.com
web-portal
components
custom-apps
web-app
Commits
dccfecdd
Commit
dccfecdd
authored
Oct 18, 2019
by
FORESTIER Fabien
Browse files
Make sure the app still starts if the user initialization fails
parent
50d2123c
Pipeline
#1783
passed with stages
in 17 minutes and 53 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/app/app.module.ts
View file @
dccfecdd
...
...
@@ -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
,
},
],
...
...
src/i18n/traductions.fr.ts
View file @
dccfecdd
...
...
@@ -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 !
'
,
...
...
src/i18n/traductions.ts
View file @
dccfecdd
...
...
@@ -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 !
'
,
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment