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

hide login button & change redirection according to conf

parent c6285db9
No related branches found
No related tags found
1 merge request!185REDMINE_ISSUE-12589
......@@ -9,6 +9,8 @@
"VUE_APP_LOGO_PATH":"/geocontrib/img/logo-neogeo-circle.png",
"VUE_APP_DJANGO_BASE":"http://localhost:8010",
"VUE_APP_DJANGO_API_BASE":"http://localhost:8010/api/",
"VUE_APP_DISABLE_LOGIN_BUTTON":false,
"VUE_APP_LOGIN_URL":"",
"DEFAULT_BASE_MAP":{
"SERVICE": "https://{s}.tile.openstreetmap.fr/osmfr/{z}/{x}/{y}.png",
"OPTIONS": {
......
......@@ -88,24 +88,30 @@
{{ userFullname || user.username || "Utilisateur inconnu" }}
</router-link>
<div
v-if="user && user.is_administrator"
v-if="USER_LEVEL_PROJECTS && project"
class="item ui label vertical no-hover"
>
<span v-if="USER_LEVEL_PROJECTS && project">
{{ USER_LEVEL_PROJECTS[project.slug] }}</span
>
{{ USER_LEVEL_PROJECTS[project.slug] }}
<br />
<span v-if="user.is_administrator">
Gestionnaire métier
</span>
</div>
<!-- // todo : find out SSO_SETTED in django -->
<a v-if="user && !SSO_SETTED" @click="logout" class="item"
><i class="ui logout icon"></i>
</a>
<router-link v-else-if="!user" to="/connexion/" class="item"
>Se Connecter</router-link
<div
v-if="user && user.is_administrator"
class="item ui label vertical no-hover"
>
Gestionnaire métier
</div>
<div v-frag v-if="!DISABLE_LOGIN_BUTTON">
<a v-if="user" @click="logout" class="item"
><i class="ui logout icon"></i>
</a>
<router-link
v-else-if="!user && !SSO_LOGIN_URL"
to="/connexion/"
class="item"
>Se connecter</router-link
>
<a v-else class="item" :href="SSO_LOGIN_URL">Se connecter</a>
</div>
</div>
</div>
</div>
......@@ -115,22 +121,30 @@
{{ userFullname || user.username || "Utilisateur inconnu" }}
</router-link>
<div
v-if="user || user.is_administrator"
v-if="USER_LEVEL_PROJECTS && project"
class="item ui label vertical no-hover"
>
<span v-if="USER_LEVEL_PROJECTS && project">
{{ USER_LEVEL_PROJECTS[project.slug] }}</span
>
{{ USER_LEVEL_PROJECTS[project.slug] }}
<br />
<span v-if="user.is_administrator"> Gestionnaire métier </span>
</div>
<!-- // todo : find out SSO_SETTED in django -->
<a v-if="user && !SSO_SETTED" @click="logout" class="item"
><i class="ui logout icon"></i>
</a>
<router-link v-else-if="!user" to="/connexion/" class="item"
>Se Connecter</router-link
<div
v-if="user && user.is_administrator"
class="item ui label vertical no-hover"
>
Gestionnaire métier
</div>
<div v-frag v-if="!DISABLE_LOGIN_BUTTON">
<a v-if="user" @click="logout" class="item"
><i class="ui logout icon"></i>
</a>
<router-link
v-else-if="!user && !SSO_LOGIN_URL"
to="/connexion/"
class="item"
>Se Connecter</router-link
>
<a v-else class="item" :href="SSO_LOGIN_URL">Se connecter</a>
</div>
</div>
</div>
</div>
......@@ -200,7 +214,6 @@ export default {
...mapState([
"projects",
"user",
"SSO_SETTED",
"USER_LEVEL_PROJECTS",
"configuration",
"messages",
......@@ -210,6 +223,12 @@ export default {
APPLICATION_NAME() {
return this.configuration.VUE_APP_APPLICATION_NAME;
},
DISABLE_LOGIN_BUTTON() {
return this.configuration.VUE_APP_DISABLE_LOGIN_BUTTON;
},
SSO_LOGIN_URL() {
return this.configuration.VUE_APP_LOGIN_URL;
},
PACKAGE_VERSION: () => process.env.PACKAGE_VERSION || "0",
logo() {
return this.configuration.VUE_APP_LOGO_PATH;
......@@ -306,8 +325,6 @@ footer {
}
.menu.container {
width: auto !important;
margin-left: 1em !important;
margin-right: 1em !important;
}
.push-right-desktop {
margin-left: auto;
......
......@@ -6,27 +6,8 @@ import feature_type from "./modules/feature_type"
import feature from "./modules/feature"
import map from "./modules/map"
// axios.defaults.headers.common['X-CSRFToken'] = (name => {
// var re = new RegExp(name + "=([^;]+)");
// var value = re.exec(document.cookie);
// return (value !== null) ? unescape(value[1]) : null;
// })('csrftoken');
Vue.use(Vuex);
// axios.defaults.withCredentials = true; // * add cookies to axios
// function updateAxiosHeader() {
// axios.defaults.headers.common['X-CSRFToken'] = (name => {
// var re = new RegExp(name + "=([^;]+)");
// var value = re.exec(document.cookie);
// return (value !== null) ? unescape(value[1]) : null;
// })('csrftoken');
// }
// // ! À vérifier s'il y a un changement de token pendant l'éxécution de l'appli
// updateAxiosHeader();
const noPermissions = { "can_view_project": true, "can_create_project": false, "can_update_project": false, "can_view_feature": true, "can_view_archived_feature": true, "can_create_feature": false, "can_update_feature": false, "can_delete_feature": false, "can_publish_feature": false, "can_create_feature_type": false, "can_view_feature_type": true, "is_project_administrator": false }
export default new Vuex.Store({
......@@ -43,7 +24,6 @@ export default new Vuex.Store({
projects: [],
last_comments: [],
staticPages: null,
SSO_SETTED: false,
USER_LEVEL_PROJECTS: null,
user_permissions: null,
levelsPermissions: [],
......@@ -81,9 +61,6 @@ export default new Vuex.Store({
SET_STATIC_PAGES(state, staticPages) {
state.staticPages = staticPages;
},
SET_SSO(state, SSO_SETTED) {
state.SSO_SETTED = SSO_SETTED;
},
SET_USER_LEVEL_PROJECTS(state, USER_LEVEL_PROJECTS) {
state.USER_LEVEL_PROJECTS = USER_LEVEL_PROJECTS;
},
......@@ -124,7 +101,7 @@ export default new Vuex.Store({
SET_CANCELLABLE_SEARCH_REQUEST(state, payload) {
state.cancellableSearchRequest.push(payload);
},
RESET_CANCELLABLE_SEARCH_REQUEST(state) {
state.cancellableSearchRequest = [];
},
......@@ -202,11 +179,13 @@ export default new Vuex.Store({
if (response && response.status === 200) {
const user = response.data.user;
commit("SET_USER", user);
//window.localStorage.setItem("user", JSON.stringify(user)); // ? nécessaire ?
}
})
.catch(() => {
router.push({ name: "login" });
//* 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) {
router.push({ name: "login" });
}
});
}
},
......@@ -229,7 +208,6 @@ export default new Vuex.Store({
},
LOGOUT({ commit, dispatch }) {
// const pageNoRedirect = ["liste-signalements", "details-type-signalement", "details-signalement", "project_detail", "mentions", "aide", "index"]
axios
.get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}logout/`)
.then((response) => {
......@@ -237,7 +215,6 @@ export default new Vuex.Store({
commit("SET_USER", false);
commit("SET_USER_LEVEL_PROJECTS", null);
dispatch("GET_USER_LEVEL_PERMISSIONS");
// if (!pageNoRedirect.includes(router.history.current.name)) router.push("/");
if (router.history.current.name !== "index") router.push("/");
}
})
......
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