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
DLCM
UI
DLCM-Portal
Commits
4efe079e
Commit
4efe079e
authored
Mar 19, 2020
by
Florent Poittevin
Browse files
fix: 921 fix infinite cancel navigation action
parent
d7794a10
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/app/stores/app.state.ts
View file @
4efe079e
import
{
PersonRole
}
from
"
@admin/models/person-role.model
"
;
import
{
HttpClient
}
from
"
@angular/common/http
"
;
import
{
ApplicationRole
,
Order
,
OrganizationalUnit
,
Person
,
Role
,
}
from
"
@models
"
;
import
{
ApplicationRoleEnum
}
from
"
@app/shared/enums/application-role.enum
"
;
import
{
LanguagesEnum
}
from
"
@app/shared/enums/languages.enum
"
;
import
{
RoutesEnum
}
from
"
@app/shared/enums/routes.enum
"
;
...
...
@@ -43,6 +36,13 @@ import {
AppUserStateModel
,
}
from
"
@app/stores/user/app-user.state
"
;
import
{
environment
}
from
"
@environments/environment
"
;
import
{
ApplicationRole
,
Order
,
OrganizationalUnit
,
Person
,
Role
,
}
from
"
@models
"
;
import
{
TranslateService
}
from
"
@ngx-translate/core
"
;
import
{
Navigate
}
from
"
@ngxs/router-plugin
"
;
import
{
...
...
@@ -66,6 +66,7 @@ import * as moment from "moment";
import
{
Observable
}
from
"
rxjs
"
;
import
{
catchError
,
mergeMap
,
tap
,
}
from
"
rxjs/operators
"
;
import
{
...
...
@@ -358,8 +359,10 @@ export class AppState extends BasicState<AppStateModel> {
}
@
Action
(
AppAction
.
Logout
)
logout
(
ctx
:
StateContext
<
AppStateModel
>
):
void
{
if
(
isFalse
(
ctx
.
getState
().
isLoggedIn
))
{
logout
(
ctx
:
StateContext
<
AppStateModel
>
):
Observable
<
any
>
{
const
isLoggedIn
=
ctx
.
getState
().
isLoggedIn
;
if
(
isFalse
(
isLoggedIn
))
{
this
.
oauthService
.
logOut
(
true
);
return
;
// PREVENT INFINITE CANCEL LOOP DUE TO MULTIPLE CALL TO THIS METHOD THAT REDIRECT TO HOME PAGE
}
ctx
.
patchState
({
...
...
@@ -371,19 +374,21 @@ export class AppState extends BasicState<AppStateModel> {
});
// Revoke tokens servers side
this
.
apiService
.
post
(
AdminResourceApiEnum
.
users
+
urlSeparator
+
ApiActionEnum
.
REVOKE_MY_TOKENS
).
subscribe
();
// Logout client side
this
.
oauthService
.
logOut
();
ctx
.
dispatch
(
new
Navigate
([
RoutesEnum
.
homePage
])).
subscribe
(()
=>
{
ctx
.
patchState
({
ignorePreventLeavePopup
:
false
,
});
if
(
isTrue
(
environment
.
reloadAfterLogout
))
{
window
.
location
.
reload
();
}
});
return
this
.
apiService
.
post
(
AdminResourceApiEnum
.
users
+
urlSeparator
+
ApiActionEnum
.
REVOKE_MY_TOKENS
).
pipe
(
tap
(()
=>
{
// Logout client side
this
.
oauthService
.
logOut
(
true
);
}),
mergeMap
(()
=>
ctx
.
dispatch
(
new
Navigate
([
RoutesEnum
.
homePage
]))),
tap
(()
=>
{
ctx
.
patchState
({
ignorePreventLeavePopup
:
false
,
});
if
(
isTrue
(
environment
.
reloadAfterLogout
))
{
window
.
location
.
reload
();
}
}),
);
}
@
Action
(
AppAction
.
CancelPreventExit
)
...
...
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