Skip to content
Snippets Groups Projects
Commit 93d1508f authored by Timothee P's avatar Timothee P :sunflower:
Browse files

fix: return user_info to load app after user related data is fetch

parent 0fbd316a
No related branches found
No related tags found
1 merge request!822REDMINE_ISSUE-18860 | Authentification GéoContrib via API OGS
......@@ -106,11 +106,8 @@ const updateOnlineStatus = () => {
const fetchDataAndInitializeApp = async () => {
await Promise.all([
store.dispatch('GET_USER_INFO'),
store.dispatch('projects/GET_PROJECTS'),
store.dispatch('GET_STATIC_PAGES'),
store.dispatch('GET_USER_LEVEL_PROJECTS'),
store.dispatch('map/GET_AVAILABLE_LAYERS'),
store.dispatch('GET_USER_LEVEL_PERMISSIONS'),
store.dispatch('GET_LEVELS_PERMISSIONS'),
store.dispatch('GET_PROJECT_ATTRIBUTES'),
]);
......
......@@ -209,14 +209,18 @@ export default new Vuex.Store({
dispatch('CONNECT_SSO_WITH_TOKEN', { token, url_redirect });
} else if (!state.user) {
// If user infos are not set, try to fetch them
axios
.get(`${state.configuration.VUE_APP_DJANGO_API_BASE}user_info/?next=${encodeURIComponent(currentUrl)}`)
return axios
.get(`${state.configuration.VUE_APP_DJANGO_API_BASE}user_info/`)
.then((response) => {
// Update the user state with received user data
if (response && response.status === 200) {
const user = response.data.user;
console.log('user', user);
commit('SET_USER', user);
// Fetch user related data
dispatch('GET_USER_LEVEL_PERMISSIONS');
dispatch('GET_USER_LEVEL_PROJECTS');
dispatch('projects/GET_PROJECTS');
return;
}
})
.catch((error) => {
......@@ -228,15 +232,16 @@ export default new Vuex.Store({
});
// Call the SSO login plateform with url to redirect after login
window.open(`${state.configuration.VUE_APP_SSO_LOGIN_URL_WITH_REDIRECT}/?url_redirect=${encodeURIComponent(currentUrl)}`, '_self');
} else if (response && response.data.redirect) {
// If the backend return a login url, the user is redirected to connect through OGS login
window.location.href = response.data.login_url;
} else if (response && response.data.redirect && state.configuration.VUE_APP_LOGIN_URL) {
// If the backend return that the user should be redirected and a custom login url exists, call the SSO login plateform
window.location.href = `${state.configuration.VUE_APP_LOGIN_URL}/?next=${encodeURIComponent(currentUrl)}`;
} else {
// If the user is not logged in, display an info message
commit('DISPLAY_MESSAGE', {
comment: `Vous n'êtes pas connecté actuellement.
Vous pouvez accéder à l'application en tant qu'utilisateur anonyme`
});
return;
}
});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment