login upon register,

removed duplicate loginAPI.js
This commit is contained in:
Ulf Gebhardt 2021-02-26 19:14:07 +01:00
parent c893c65a31
commit b581ebbdab
No known key found for this signature in database
GPG Key ID: 81308EFE29ABFEBD
3 changed files with 9 additions and 23 deletions

View File

@ -56,7 +56,8 @@ const loginAPI = {
first_name, first_name,
last_name, last_name,
password, password,
emailType: EMAIL_TYPE.DEFAULT emailType: EMAIL_TYPE.DEFAULT,
login_after_register: true
} }
try { try {
const result = await axios.post(LOGIN_API_URL + 'createUser', payload); const result = await axios.post(LOGIN_API_URL + 'createUser', payload);

View File

@ -1,19 +0,0 @@
// TODO move this
const LOGIN_API_URL = 'http://localhost/login_api/'
// define a mixin object
const loginAPI = {
actions: {
login: async () => {
return axios.post(LOGIN_API_URL + 'unsecureLogin', data);
},
creatUser : async () => {
return axios.post(LOGIN_API_URL + 'createUser', data);
},
logout: async () => {
return axios.post(LOGIN_API_URL + 'logout', data);
},
}
}
export default loginAPI

View File

@ -59,13 +59,17 @@ export const store = new Vuex.Store({
dispatch('logout') dispatch('logout')
} }
}, },
createUser: async ({ dispatch }, data) => { createUser: async ({ commit, dispatch }, data) => {
//console.log('action: createUser') //console.log('action: createUser')
//console.log('data ', data) //console.log('data ', data)
const result = await loginAPI.create(data.email,data.first_name,data.last_name,data.password) const result = await loginAPI.create(data.email,data.first_name,data.last_name,data.password)
if( result.success ){ if( result.success ){
// TODO We are not logged in, we need to do that manually. console.log(result)
// TODO show user a success message commit('session_id', result.result.data.session_id)
commit('email', data.email)
$cookies.set('gdd_session_id', result.result.data.session_id);
$cookies.set('gdd_u', data.email);
router.push('/KontoOverview')
} else { } else {
// Register failed, we perform a logout // Register failed, we perform a logout
dispatch('logout') dispatch('logout')