From b581ebbdab1c06da457bbb4e16941fd2d3ecc1c5 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 26 Feb 2021 19:14:07 +0100 Subject: [PATCH] login upon register, removed duplicate loginAPI.js --- frontend/src/apis/loginAPI.js | 3 ++- frontend/src/mixins/loginAPI.js | 19 ------------------- frontend/src/store/store.js | 10 +++++++--- 3 files changed, 9 insertions(+), 23 deletions(-) delete mode 100644 frontend/src/mixins/loginAPI.js diff --git a/frontend/src/apis/loginAPI.js b/frontend/src/apis/loginAPI.js index 3a58957ea..8b944ea84 100644 --- a/frontend/src/apis/loginAPI.js +++ b/frontend/src/apis/loginAPI.js @@ -56,7 +56,8 @@ const loginAPI = { first_name, last_name, password, - emailType: EMAIL_TYPE.DEFAULT + emailType: EMAIL_TYPE.DEFAULT, + login_after_register: true } try { const result = await axios.post(LOGIN_API_URL + 'createUser', payload); diff --git a/frontend/src/mixins/loginAPI.js b/frontend/src/mixins/loginAPI.js deleted file mode 100644 index d102f381d..000000000 --- a/frontend/src/mixins/loginAPI.js +++ /dev/null @@ -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 \ No newline at end of file diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js index 5ff0ac17f..052d2bfda 100644 --- a/frontend/src/store/store.js +++ b/frontend/src/store/store.js @@ -59,13 +59,17 @@ export const store = new Vuex.Store({ dispatch('logout') } }, - createUser: async ({ dispatch }, data) => { + createUser: async ({ commit, dispatch }, data) => { //console.log('action: createUser') //console.log('data ', data) const result = await loginAPI.create(data.email,data.first_name,data.last_name,data.password) if( result.success ){ - // TODO We are not logged in, we need to do that manually. - // TODO show user a success message + console.log(result) + 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 { // Register failed, we perform a logout dispatch('logout')