added csrftoken to register REST call
This commit is contained in:
parent
eb6cb2db27
commit
55bb48c750
File diff suppressed because one or more lines are too long
|
@ -11,6 +11,7 @@ export default {
|
||||||
// username: '',
|
// username: '',
|
||||||
mail:'',
|
mail:'',
|
||||||
token: null,
|
token: null,
|
||||||
|
csrftoken: null,
|
||||||
logout_token: null,
|
logout_token: null,
|
||||||
isloggedin: false,
|
isloggedin: false,
|
||||||
isAdmin: false,
|
isAdmin: false,
|
||||||
|
@ -24,6 +25,9 @@ export default {
|
||||||
|
|
||||||
// mutations
|
// mutations
|
||||||
mutations : {
|
mutations : {
|
||||||
|
SetCsrftoken (state, token) {
|
||||||
|
state.csrftoken = token
|
||||||
|
},
|
||||||
setToken (state, data) {
|
setToken (state, data) {
|
||||||
state.uid = data.current_user.uid
|
state.uid = data.current_user.uid
|
||||||
// state.username = data.username
|
// state.username = data.username
|
||||||
|
@ -78,7 +82,13 @@ export default {
|
||||||
actions : {
|
actions : {
|
||||||
userRegister({ dispatch, commit, state }, credentials){
|
userRegister({ dispatch, commit, state }, credentials){
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
REST.post('/user/register?_format=json', credentials)
|
REST.get('/session/token')
|
||||||
|
.then(({token}) => {
|
||||||
|
commit('SetCsrftoken', token)
|
||||||
|
REST.post('/user/register?_format=json',
|
||||||
|
credentials,
|
||||||
|
{'X-CSRF-Token':state.csrftoken}
|
||||||
|
)
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
console.log('user REST registered', data);
|
console.log('user REST registered', data);
|
||||||
dispatch('userLogin', credentials)
|
dispatch('userLogin', credentials)
|
||||||
|
@ -90,6 +100,8 @@ export default {
|
||||||
console.warn('Issue with register', error)
|
console.warn('Issue with register', error)
|
||||||
Promise.reject(error)
|
Promise.reject(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
userLogin({ dispatch, commit, state }, credentials){
|
userLogin({ dispatch, commit, state }, credentials){
|
||||||
|
|
Loading…
Reference in New Issue