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
71a1ae7b
Commit
71a1ae7b
authored
5 months ago
by
Timothee P
Browse files
Options
Downloads
Patches
Plain Diff
feat: check user status at intervals with SSO
parent
7decb12b
No related branches found
No related tags found
1 merge request
!858
REDMINE_ISSUE-18905 | Gestion du signin/signout erronée
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/AppHeader.vue
+5
-1
5 additions, 1 deletion
src/components/AppHeader.vue
src/main.js
+43
-0
43 additions, 0 deletions
src/main.js
with
48 additions
and
1 deletion
src/components/AppHeader.vue
+
5
−
1
View file @
71a1ae7b
...
...
@@ -169,7 +169,7 @@
<div
class=
"desktop flex push-right-desktop"
>
<div
v-if=
"!isOnline"
class=
"item"
class=
"item
network-icon
"
>
<span
data-tooltip=
"Vous êtes hors-ligne,
...
...
@@ -362,6 +362,10 @@ export default {
text-align: center;
}
.network-icon {
padding: .5rem !important;
}
.crossed-out {
position: relative;
padding: .2em;
...
...
This diff is collapsed.
Click to expand it.
src/main.js
+
43
−
0
View file @
71a1ae7b
...
...
@@ -101,6 +101,44 @@ const updateOnlineStatus = () => {
},
2000
);
};
/**
* Regularly updates the user status if using external auth to keep the frontend updated with backend.
*/
const
updateUserStatus
=
()
=>
{
setInterval
(()
=>
{
if
(
navigator
.
onLine
)
{
axios
.
get
(
`
${
store
.
state
.
configuration
.
VUE_APP_DJANGO_API_BASE
}
user_info/`
)
.
then
((
response
)
=>
{
if
(
response
&&
response
.
status
===
200
)
{
const
user
=
response
.
data
.
user
;
if
(
!
store
.
state
.
user
&&
user
)
{
store
.
commit
(
'
SET_USER
'
,
user
);
store
.
commit
(
'
DISPLAY_MESSAGE
'
,
{
level
:
'
positive
'
,
comment
:
`Bienvenue à nouveau ! Vous êtes reconnecté au service d'authentification (SSO).`
});
store
.
dispatch
(
'
GET_USER_LEVEL_PERMISSIONS
'
);
store
.
dispatch
(
'
GET_USER_LEVEL_PROJECTS
'
);
}
}
})
.
catch
(()
=>
{
if
(
store
.
state
.
user
)
{
store
.
commit
(
'
SET_USER
'
,
false
);
store
.
commit
(
'
DISPLAY_MESSAGE
'
,
{
level
:
'
negative
'
,
comment
:
`Oups ! Vous avez été déconnecté du service d'authentification (SSO).
Reconnectez-vous ou continuez en mode anonyme.`
});
store
.
dispatch
(
'
GET_USER_LEVEL_PERMISSIONS
'
);
store
.
dispatch
(
'
GET_USER_LEVEL_PROJECTS
'
);
}
})
}
},
10000
);
};
/**
* Fetches initial data for the application and initializes the Vue instance.
*/
...
...
@@ -131,6 +169,11 @@ const onConfigLoaded = async (config) => {
// Update the online status at regular intervals.
updateOnlineStatus
();
// Update the user status at regular intervals if using external auth.
if
(
config
.
VUE_APP_LOGIN_URL
&&
config
.
VUE_APP_DISABLE_LOGIN_BUTTON
)
{
updateUserStatus
();
}
// Set the document title and favicon from the configuration.
document
.
title
=
`
${
config
.
VUE_APP_APPLICATION_NAME
}
${
config
.
VUE_APP_APPLICATION_ABSTRACT
}
`
;
setFavicon
(
config
.
VUE_APP_APPLICATION_FAVICO
);
...
...
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