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: '',
|
||||
mail:'',
|
||||
token: null,
|
||||
csrftoken: null,
|
||||
logout_token: null,
|
||||
isloggedin: false,
|
||||
isAdmin: false,
|
||||
|
@ -24,6 +25,9 @@ export default {
|
|||
|
||||
// mutations
|
||||
mutations : {
|
||||
SetCsrftoken (state, token) {
|
||||
state.csrftoken = token
|
||||
},
|
||||
setToken (state, data) {
|
||||
state.uid = data.current_user.uid
|
||||
// state.username = data.username
|
||||
|
@ -78,7 +82,13 @@ export default {
|
|||
actions : {
|
||||
userRegister({ dispatch, commit, state }, credentials){
|
||||
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 }) => {
|
||||
console.log('user REST registered', data);
|
||||
dispatch('userLogin', credentials)
|
||||
|
@ -90,6 +100,8 @@ export default {
|
|||
console.warn('Issue with register', error)
|
||||
Promise.reject(error)
|
||||
})
|
||||
|
||||
})
|
||||
})
|
||||
},
|
||||
userLogin({ dispatch, commit, state }, credentials){
|
||||
|
|
Loading…
Reference in New Issue