Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Géocontrib Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GéoContrib
Géocontrib Frontend
Commits
b9f885f9
Commit
b9f885f9
authored
2 weeks ago
by
Timothee P
Browse files
Options
Downloads
Patches
Plain Diff
fix: detection de redirection pour logout SSO
parent
170fc9d8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!866
REDMINE_ISSUE-24200 | Déconnexion OGS <-> GC
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main.js
+26
-21
26 additions, 21 deletions
src/main.js
with
26 additions
and
21 deletions
src/main.js
+
26
−
21
View file @
b9f885f9
...
@@ -104,15 +104,33 @@ const updateOnlineStatus = () => {
...
@@ -104,15 +104,33 @@ const updateOnlineStatus = () => {
/**
/**
* Regularly updates the user status if using external auth to keep the frontend updated with backend.
* Regularly updates the user status if using external auth to keep the frontend updated with backend.
*/
*/
function
handleLogout
()
{
if
(
store
.
state
.
user
)
{
store
.
dispatch
(
'
LOGOUT
'
);
store
.
commit
(
'
DISPLAY_MESSAGE
'
,
{
level
:
'
negative
'
,
comment
:
`Vous avez été déconnecté du service d'authentification.
Reconnectez-vous ou continuez en mode anonyme.`
});
store
.
dispatch
(
'
GET_USER_LEVEL_PROJECTS
'
);
}
}
const
updateUserStatus
=
()
=>
{
const
updateUserStatus
=
()
=>
{
setInterval
(()
=>
{
setInterval
(()
=>
{
if
(
navigator
.
onLine
)
{
if
(
navigator
.
onLine
)
{
axios
axios
.
get
(
`
${
store
.
state
.
configuration
.
VUE_APP_DJANGO_API_BASE
}
user_info/`
)
.
get
(
`
${
store
.
state
.
configuration
.
VUE_APP_DJANGO_API_BASE
}
user_info/`
)
.
then
((
response
)
=>
{
.
then
((
response
)
=>
{
if
(
response
&&
response
.
status
===
200
)
{
const
user
=
response
.
data
?.
user
||
null
;
const
user
=
response
.
data
.
user
;
if
(
!
store
.
state
.
user
&&
user
)
{
if
(
response
.
status
===
302
)
{
console
.
warn
(
"
Redirection détectée vers :
"
,
response
.
headers
.
location
||
response
.
request
.
responseURL
);
}
if
(
response
.
status
===
200
&&
user
)
{
// Cas où l'utilisateur est bien authentifié
if
(
!
store
.
state
.
user
)
{
store
.
commit
(
'
SET_USER
'
,
user
);
store
.
commit
(
'
SET_USER
'
,
user
);
store
.
commit
(
'
DISPLAY_MESSAGE
'
,
{
store
.
commit
(
'
DISPLAY_MESSAGE
'
,
{
level
:
'
positive
'
,
level
:
'
positive
'
,
...
@@ -121,28 +139,15 @@ const updateUserStatus = () => {
...
@@ -121,28 +139,15 @@ const updateUserStatus = () => {
store
.
dispatch
(
'
GET_USER_LEVEL_PERMISSIONS
'
);
store
.
dispatch
(
'
GET_USER_LEVEL_PERMISSIONS
'
);
store
.
dispatch
(
'
GET_USER_LEVEL_PROJECTS
'
);
store
.
dispatch
(
'
GET_USER_LEVEL_PROJECTS
'
);
}
}
}
else
if
(
store
.
state
.
user
)
{
}
else
if
(
!
user
)
{
// Lorsqu'un utilisateur est déconnecté du SSO, la requête de vérification de session envoyée à l'API de l'application échoue avec une erreur 400.
// Lorsqu'un utilisateur est déconnecté du SSO, la requête de vérification de session envoyée à l'API de l'application échoue avec une erreur 400.
// On force la déconnexion de l'utilisateur dans ce cas.
// On force la déconnexion de l'utilisateur dans ce cas.
store
.
dispatch
(
'
LOGOUT
'
)
handleLogout
();
store
.
commit
(
'
DISPLAY_MESSAGE
'
,
{
level
:
'
negative
'
,
comment
:
`Vous avez été déconnecté du service d'authentification.
Reconnectez-vous ou continuez en mode anonyme.`
});
}
}
})
})
.
catch
(()
=>
{
.
catch
(
error
=>
{
if
(
store
.
state
.
user
)
{
console
.
error
(
"
Erreur API :
"
,
error
);
store
.
commit
(
'
SET_USER
'
,
false
);
handleLogout
();
store
.
commit
(
'
DISPLAY_MESSAGE
'
,
{
level
:
'
negative
'
,
comment
:
`Vous avez été déconnecté du service d'authentification.
Reconnectez-vous ou continuez en mode anonyme.`
});
store
.
dispatch
(
'
GET_USER_LEVEL_PERMISSIONS
'
);
store
.
dispatch
(
'
GET_USER_LEVEL_PROJECTS
'
);
}
});
});
}
}
},
10000
);
},
10000
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment