fixed user logout bug
This commit is contained in:
parent
b5fc279340
commit
81ab0ccfd7
@ -114,6 +114,7 @@
|
|||||||
"drupal/jsonapi_extras": "^3.21",
|
"drupal/jsonapi_extras": "^3.21",
|
||||||
"drupal/login_history": "^2.0",
|
"drupal/login_history": "^2.0",
|
||||||
"drupal/login_tracker": "^2.0",
|
"drupal/login_tracker": "^2.0",
|
||||||
|
"drupal/logout_token": "^1.0",
|
||||||
"drupal/mailjet": "^4.0",
|
"drupal/mailjet": "^4.0",
|
||||||
"drupal/maillog": "^1.1",
|
"drupal/maillog": "^1.1",
|
||||||
"drupal/masquerade": "^2.0",
|
"drupal/masquerade": "^2.0",
|
||||||
|
46
composer.lock
generated
46
composer.lock
generated
@ -4,7 +4,7 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "a29125e1001e64fb0fe09951db6e8c9f",
|
"content-hash": "b289f714c59ac7e099677e46f2bded84",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "algolia/places",
|
"name": "algolia/places",
|
||||||
@ -9065,6 +9065,50 @@
|
|||||||
"source": "https://git.drupalcode.org/project/login_tracker"
|
"source": "https://git.drupalcode.org/project/login_tracker"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "drupal/logout_token",
|
||||||
|
"version": "1.0.3",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://git.drupalcode.org/project/logout_token.git",
|
||||||
|
"reference": "1.0.3"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://ftp.drupal.org/files/projects/logout_token-1.0.3.zip",
|
||||||
|
"reference": "1.0.3",
|
||||||
|
"shasum": "d11d7c65336ce8558e98a0dfad59bc7e811f2003"
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"drupal/core": "^8 || ^9 || ^10"
|
||||||
|
},
|
||||||
|
"type": "drupal-module",
|
||||||
|
"extra": {
|
||||||
|
"drupal": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"datestamp": "1690811062",
|
||||||
|
"security-coverage": {
|
||||||
|
"status": "not-covered",
|
||||||
|
"message": "Project has not opted into security advisory coverage!"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packages.drupal.org/8/downloads",
|
||||||
|
"license": [
|
||||||
|
"GPL-2.0-or-later"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "sraseef",
|
||||||
|
"homepage": "https://www.drupal.org/user/2825415"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Provides an endpoint to retrieve the logout token during user sessions.",
|
||||||
|
"homepage": "https://www.drupal.org/project/logout_token",
|
||||||
|
"support": {
|
||||||
|
"source": "https://git.drupalcode.org/project/logout_token"
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "drupal/mailjet",
|
"name": "drupal/mailjet",
|
||||||
"version": "4.0.0",
|
"version": "4.0.0",
|
||||||
|
@ -124,6 +124,7 @@ module:
|
|||||||
locale: 0
|
locale: 0
|
||||||
login_history: 0
|
login_history: 0
|
||||||
login_tracker: 0
|
login_tracker: 0
|
||||||
|
logout_token: 0
|
||||||
mailjet: 0
|
mailjet: 0
|
||||||
mailjet_commerce: 0
|
mailjet_commerce: 0
|
||||||
mailjet_event: 0
|
mailjet_event: 0
|
||||||
|
@ -2,3 +2,4 @@ description: "L'inspiration par la matière"
|
|||||||
lang: fr
|
lang: fr
|
||||||
start_url: /
|
start_url: /
|
||||||
scope: /
|
scope: /
|
||||||
|
dir: auto
|
||||||
|
File diff suppressed because one or more lines are too long
Binary file not shown.
@ -13,7 +13,7 @@
|
|||||||
class="mdi mdi-settings"
|
class="mdi mdi-settings"
|
||||||
title="admin"
|
title="admin"
|
||||||
></a>
|
></a>
|
||||||
<a href="/user/logout"
|
<a href="#"
|
||||||
@click.prevent="onLogout()"
|
@click.prevent="onLogout()"
|
||||||
class="mdi mdi-logout"
|
class="mdi mdi-logout"
|
||||||
title="logout"
|
title="logout"
|
||||||
|
@ -41,6 +41,9 @@ export default {
|
|||||||
console.log('SetCsrftoken', token)
|
console.log('SetCsrftoken', token)
|
||||||
state.csrf_token = token
|
state.csrf_token = token
|
||||||
},
|
},
|
||||||
|
SetLogouttoken (state, token) {
|
||||||
|
state.logout_token = token
|
||||||
|
},
|
||||||
setToken (state, data) {
|
setToken (state, data) {
|
||||||
console.log('setToken', data)
|
console.log('setToken', data)
|
||||||
state.uid = data.current_user.uid
|
state.uid = data.current_user.uid
|
||||||
@ -183,10 +186,10 @@ export default {
|
|||||||
},
|
},
|
||||||
userLogin ({ dispatch, commit, state }, credentials) {
|
userLogin ({ dispatch, commit, state }, credentials) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
dispatch('getToken', credentials)
|
dispatch('postUserLogin', credentials)
|
||||||
// TODO: catch failed login
|
// TODO: catch failed login
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
console.log('userLogin dispatch getToken response', response)
|
console.log('userLogin dispatch postUserLogin response', response)
|
||||||
|
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
commit('setToken', response.data)
|
commit('setToken', response.data)
|
||||||
@ -194,7 +197,7 @@ export default {
|
|||||||
console.log('User Loggedin', state.isAdmin, state.isAdherent)
|
console.log('User Loggedin', state.isAdmin, state.isAdherent)
|
||||||
// have to reload systematicly because of autologout library not loaded if not logged in the begining
|
// have to reload systematicly because of autologout library not loaded if not logged in the begining
|
||||||
if (state.isAdmin) {
|
if (state.isAdmin) {
|
||||||
window.location.reload()
|
// window.location.reload()
|
||||||
}
|
}
|
||||||
if (state.isAdherent) {
|
if (state.isAdherent) {
|
||||||
// router.push({
|
// router.push({
|
||||||
@ -202,7 +205,7 @@ export default {
|
|||||||
// })
|
// })
|
||||||
// // TODO: openCloseHamMenu(false)
|
// // TODO: openCloseHamMenu(false)
|
||||||
// dispatch('Common/openCloseHamMenu', false)
|
// dispatch('Common/openCloseHamMenu', false)
|
||||||
window.location = '/base'
|
// window.location = '/base'
|
||||||
}
|
}
|
||||||
// else {
|
// else {
|
||||||
// // * window.location.reload()
|
// // * window.location.reload()
|
||||||
@ -211,18 +214,18 @@ export default {
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
commit('setLoginMessage', response.data.message)
|
commit('setLoginMessage', response.data.message)
|
||||||
console.warn('Issue with getToken', response)
|
console.warn('Issue with postUserLogin', response)
|
||||||
console.log('user loggein failed')
|
console.log('user loggein failed')
|
||||||
Promise.reject(new Error('user loggein failed'))
|
Promise.reject(new Error('user loggein failed'))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.warn('Issue with Dispatch getToken', error)
|
console.warn('Issue with Dispatch postUserLogin', error)
|
||||||
Promise.reject(error)
|
Promise.reject(error)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getToken ({ dispatch, commit, state }, credentials) {
|
postUserLogin ({ dispatch, commit, state }, credentials) {
|
||||||
return REST.post('/user/login?_format=json',
|
return REST.post('/user/login?_format=json',
|
||||||
credentials,
|
credentials,
|
||||||
{
|
{
|
||||||
@ -237,6 +240,11 @@ export default {
|
|||||||
console.log('csrftoken', data)
|
console.log('csrftoken', data)
|
||||||
commit('SetCsrftoken', data)
|
commit('SetCsrftoken', data)
|
||||||
console.log('state.csrf_token', state.csrf_token)
|
console.log('state.csrf_token', state.csrf_token)
|
||||||
|
// INFO this endpoiunt needs https://www.drupal.org/project/logout_token
|
||||||
|
REST.get('/session/logout/token')
|
||||||
|
.then(({ data }) => {
|
||||||
|
console.log('logout_token', data)
|
||||||
|
commit('SetLogouttoken', data)
|
||||||
const params = {
|
const params = {
|
||||||
token: state.csrf_token
|
token: state.csrf_token
|
||||||
}
|
}
|
||||||
@ -261,6 +269,11 @@ export default {
|
|||||||
Promise.reject(error)
|
Promise.reject(error)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.warn('Issue with getUser', error)
|
||||||
|
Promise.reject(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
// getUserProfiles ({ dispatch, commit, state }, pid) {
|
// getUserProfiles ({ dispatch, commit, state }, pid) {
|
||||||
@ -424,14 +437,20 @@ export default {
|
|||||||
commit('closeFlagColl')
|
commit('closeFlagColl')
|
||||||
},
|
},
|
||||||
userLogout ({ commit, state }) {
|
userLogout ({ commit, state }) {
|
||||||
const credentials = qs.stringify({
|
const params = qs.stringify({
|
||||||
token: state.csrf_token
|
// format: 'json'
|
||||||
|
// token: state.logout_token
|
||||||
})
|
})
|
||||||
REST.post('/user/logout', credentials)
|
const config = {
|
||||||
|
headers: {
|
||||||
|
'X-CSRF-Token': state.csrf_token
|
||||||
|
}
|
||||||
|
}
|
||||||
|
REST.post('/user/logout?format=json&token=' + state.logout_token, params, config)
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
console.log('userLogout resp', resp)
|
console.log('userLogout resp', resp)
|
||||||
commit('setLoggedOut')
|
// commit('setLoggedOut')
|
||||||
// window.location.reload(true) ???
|
// window.location.reload(true)
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.warn('Issue with logout', error)
|
console.warn('Issue with logout', error)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user