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

disable index button if shared project on login page

parent 1680906d
No related branches found
No related tags found
2 merge requests!295Version 3.0.0,!294REDMINE_ISSUE-13086
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<div class="menu container"> <div class="menu container">
<div class="ui inverted icon menu"> <div class="ui inverted icon menu">
<router-link <router-link
:is="isSharedProject ? 'span' : 'router-link'"
:to="isSharedProject ? '' : '/'" :to="isSharedProject ? '' : '/'"
:class="['header item', {disable: isSharedProject}]" :class="['header item', {disable: isSharedProject}]"
> >
...@@ -122,7 +123,7 @@ ...@@ -122,7 +123,7 @@
</a> </a>
<router-link <router-link
v-else-if="!user && !SSO_LOGIN_URL" v-else-if="!user && !SSO_LOGIN_URL"
to="/connexion/" :to="{ name : 'login' }"
class="item" class="item"
> >
Se connecter Se connecter
...@@ -175,7 +176,7 @@ ...@@ -175,7 +176,7 @@
</a> </a>
<router-link <router-link
v-else-if="!user && !SSO_LOGIN_URL" v-else-if="!user && !SSO_LOGIN_URL"
to="/connexion/" :to="{ name : 'login' }"
class="item" class="item"
> >
Se Connecter Se Connecter
......
...@@ -4,10 +4,6 @@ import Projects from '../views/Projects.vue'; ...@@ -4,10 +4,6 @@ import Projects from '../views/Projects.vue';
Vue.use(VueRouter); Vue.use(VueRouter);
//* store initial route before redirect to login page
//* in order to turn back to shared project afterwards (not memorized in router history at page load)
window.initialRoute = window.location.href;
let projectBase = 'projet'; let projectBase = 'projet';
if (window.location.pathname.includes('projet-partage')) { if (window.location.pathname.includes('projet-partage')) {
projectBase = 'projet-partage'; projectBase = 'projet-partage';
...@@ -20,7 +16,7 @@ const routes = [ ...@@ -20,7 +16,7 @@ const routes = [
component: Projects component: Projects
}, },
{ {
path: '/connexion/', path: `${projectBase === 'projet' ? '': '/' + projectBase + '/:slug'}/connexion/`,
name: 'login', name: 'login',
component: () => import('../views/registration/Login.vue') component: () => import('../views/registration/Login.vue')
}, },
......
...@@ -138,21 +138,8 @@ export default new Vuex.Store({ ...@@ -138,21 +138,8 @@ export default new Vuex.Store({
}) })
.then((response) => { .then((response) => {
if (response.status === 200 && response.data) { if (response.status === 200 && response.data) {
// * use stored previous route to go back after login if page not open on login at first
let routerHistory = '';
if (router.options.routerHistory[0] !== undefined) {
routerHistory = router.options.routerHistory[0].name !== 'login' ? router.options.routerHistory : '/';
} else {
routerHistory = '/';
}
commit('SET_USER', response.data.user); commit('SET_USER', response.data.user);
dispatch('REDIRECT_AFTER_LOGIN');
if (routerHistory === '/' && window.initialRoute.includes('projet-partage')) {
window.location.replace(window.initialRoute);
} else { // ToDo : not working at page load, routerHistory filled afterwards, could try history.back()
router.push(routerHistory[routerHistory.length - 1] || '/');
}
dispatch('GET_USER_LEVEL_PROJECTS'); dispatch('GET_USER_LEVEL_PROJECTS');
dispatch('GET_USER_LEVEL_PERMISSIONS'); dispatch('GET_USER_LEVEL_PERMISSIONS');
return response.status; return response.status;
...@@ -165,6 +152,23 @@ export default new Vuex.Store({ ...@@ -165,6 +152,23 @@ export default new Vuex.Store({
} }
}, },
REDIRECT_AFTER_LOGIN() {
// * use stored previous route to go back after login if page not open on login at first
let routerHistory = '';
if (router.options.routerHistory[0] !== undefined) {
routerHistory = router.options.routerHistory[0].name !== 'login' ? router.options.routerHistory : '/';
} else {
routerHistory = '/';
}
const slug = router.history.current.params.slug;
if (slug) {
router.push({ name: 'project_detail', params: { slug } });
} else { //* not working at page load, routerHistory filled afterwards, could try history.back()
router.push(routerHistory[routerHistory.length - 1] || '/');
}
},
USER_INFO({ state, commit }) { USER_INFO({ state, commit }) {
if (!state.user) { if (!state.user) {
axios axios
...@@ -178,7 +182,15 @@ export default new Vuex.Store({ ...@@ -178,7 +182,15 @@ export default new Vuex.Store({
.catch(() => { .catch(() => {
//* if an url to redirect to an external authentification system is present, do not redirect to the login page //* if an url to redirect to an external authentification system is present, do not redirect to the login page
if (!state.configuration.VUE_APP_LOGIN_URL) { if (!state.configuration.VUE_APP_LOGIN_URL) {
router.push({ name: 'login' }); const url = window.location.href;
console.log({ url });
console.log(url.includes('projet-partage'));
if (url.includes('projet-partage')) {
const slug = url.split('projet-partage/')[1];
router.push({ name: 'login', params: { slug } });
} else {
router.push({ name: 'login' });
}
} }
}); });
} }
......
...@@ -103,9 +103,9 @@ export default { ...@@ -103,9 +103,9 @@ export default {
if (this.$store.state.user) { if (this.$store.state.user) {
this.$store.commit( this.$store.commit(
'DISPLAY_MESSAGE', 'DISPLAY_MESSAGE',
{ comment: "Vous êtes déjà connecté, vous allez être redirigé vers la page d'accueil." } { comment: 'Vous êtes déjà connecté, vous allez être redirigé vers la page précédente.' }
); );
setTimeout(() => this.$router.push('/'), 3100); setTimeout(() => this.$store.dispatch('REDIRECT_AFTER_LOGIN'), 3100);
} }
}, },
methods: { methods: {
......
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