Skip to content
Snippets Groups Projects
Commit 9d86e0a8 authored by Florent Lavelle's avatar Florent Lavelle Committed by m431m
Browse files

Add VUE_APP_EXTERNAL_LOGOUT_URL + VUE_APP_EXTERNAL_LOGOUT_METHOD

parent 17244b6d
No related branches found
No related tags found
No related merge requests found
......@@ -53,6 +53,8 @@ build_development:
VUE_APP_USERGROUP_API_PATH=/fr/usergroup/\n
VUE_APP_EXTERNAL_LOGIN=true\n
VUE_APP_EXTERNAL_LOGIN_URL=http://127.0.0.1:80/oidc/authenticate\n
VUE_APP_EXTERNAL_LOGOUT_URL=http://127.0.0.1:80/oidc/logout/?redirect_uri=/fr/login/signout\n
VUE_APP_EXTERNAL_LOGOUT_METHOD=get\n
VUE_APP_EXTERNAL_LOGIN_LABEL=Se connecter avec mon compte FooBar\n
" > .env
- npm run build
......
......@@ -46,6 +46,8 @@ VUE_APP_LOGIN_API_PASSWORD=CHANGE_ME
# External auth
VUE_APP_EXTERNAL_LOGIN=true
VUE_APP_EXTERNAL_LOGIN_URL=http://127.0.0.1/oidc/authenticate
VUE_APP_EXTERNAL_LOGOUT_URL=http://127.0.0.1/oidc/logout/?redirect_uri=/fr/login/signout
VUE_APP_EXTERNAL_LOGOUT_METHOD=get
VUE_APP_EXTERNAL_LOGIN_LABEL=Connect with...
```
......
import client from '@/api/loginAPI.js';
import i18n from '@/i18n';
import axios from 'axios';
const state = {
logged: null,
......@@ -9,11 +10,17 @@ const state = {
const getters = {
};
export const GET_SIGNOUT = 'GET_SIGNOUT';
const actions = {
[GET_SIGNOUT]: async ({ commit }) => {
await client.signOut()
GET_SIGNOUT: async ({ commit }) => {
const EXTERNAL_LOGOUT_URL = process.env.VUE_APP_EXTERNAL_LOGOUT_URL;
const EXTERNAL_LOGOUT_METHOD = process.env.VUE_APP_EXTERNAL_LOGOUT_METHOD;
Promise.all([
client.signOut(),
EXTERNAL_LOGOUT_URL ?
axios[EXTERNAL_LOGOUT_METHOD ? EXTERNAL_LOGOUT_METHOD : 'get'](EXTERNAL_LOGOUT_URL) :
null
])
.then(
() => {
commit('SET_ERROR', undefined);
......@@ -33,18 +40,16 @@ const actions = {
},
};
export const SET_ERROR = 'SET_ERROR';
export const SET_LOGGED = 'SET_LOGGED';
const mutations = {
[SET_LOGGED]: (state, value) => {
SET_LOGGED: (state, value) => {
if (value === true) {
state.logged = true;
} else {
state.logged = false;
}
},
[SET_ERROR]: (state, payload) => {
SET_ERROR: (state, payload) => {
state.error = payload;
},
};
......
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