mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
login upon register,
removed duplicate loginAPI.js
This commit is contained in:
parent
c893c65a31
commit
b581ebbdab
@ -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);
|
||||||
|
|||||||
@ -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
|
|
||||||
@ -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')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user