From 89205d531fd8edc91aa965468bf6cda1bf4a7c28 Mon Sep 17 00:00:00 2001 From: Ulf Gebhardt Date: Fri, 26 Feb 2021 19:32:45 +0100 Subject: [PATCH] corrected some comments, new communityAPI stub --- frontend/src/apis/communityAPI.js | 11 +++ frontend/src/apis/loginAPI.js | 1 - frontend/src/store/store.js | 115 ++---------------------------- 3 files changed, 16 insertions(+), 111 deletions(-) create mode 100644 frontend/src/apis/communityAPI.js diff --git a/frontend/src/apis/communityAPI.js b/frontend/src/apis/communityAPI.js new file mode 100644 index 000000000..2dab2dc8b --- /dev/null +++ b/frontend/src/apis/communityAPI.js @@ -0,0 +1,11 @@ +import axios from 'axios'; + +// TODO move this +const COMMUNITY_API_URL = '' + +const communityAPI = { + call: async (param1, param2) => { + }, +} + +export default communityAPI \ No newline at end of file diff --git a/frontend/src/apis/loginAPI.js b/frontend/src/apis/loginAPI.js index 8b944ea84..2f728442d 100644 --- a/frontend/src/apis/loginAPI.js +++ b/frontend/src/apis/loginAPI.js @@ -9,7 +9,6 @@ const EMAIL_TYPE = { ADMIN: 5, // if user was registered by an admin } -// define a mixin object const loginAPI = { login: async (email, password) => { const payload = { diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js index 052d2bfda..7a96e232e 100644 --- a/frontend/src/store/store.js +++ b/frontend/src/store/store.js @@ -25,9 +25,9 @@ export const store = new Vuex.Store({ }, // Retrieve a state variable getters: { - isLoggedIn: (state /*, getters */) => { - return state.session_id !== null; - } + //isLoggedIn: (state /*, getters */) => { + // return state.session_id !== null; + //} }, // Syncronous mutation of the state mutations: { @@ -45,10 +45,7 @@ export const store = new Vuex.Store({ login: async ({ dispatch, commit }, data) => { console.log('action: login') const result = await loginAPI.login(data.email,data.password) - console.log(result) if( result.success ){ - // We are not logged in, we need to do that manually. - // 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); @@ -60,11 +57,9 @@ export const store = new Vuex.Store({ } }, createUser: async ({ commit, dispatch }, data) => { - //console.log('action: createUser') - //console.log('data ', data) + console.log('action: createUser') const result = await loginAPI.create(data.email,data.first_name,data.last_name,data.password) if( result.success ){ - 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); @@ -118,104 +113,4 @@ export const store = new Vuex.Store({ }); } } -}) - -/* - login (state, logindata) { - //console.log("Im Store LOGIN() start " ) - //console.log("logon state =>", state ) - //console.log("logon TEST =>", logindata ) - axios.post("http://localhost/login_api/unsecureLogin", logindata).then((ldata) => { - - console.log("Im Store LOGIN() axios then.statusText ", ldata); - if (ldata.statusText === "OK") { - //console.log("STORE login() ldatasession_id", ldata.data.session_id) - state.is_auth = true - state.active = true - state.session_id= ldata.data.session_id - state.user.email = logindata.email - $cookies.set('gdd_is_auth','true'); - $cookies.set('gdd_session_id', ldata.data.session_id); - $cookies.set('gdd_u',logindata.email); - console.log("cookie ? GRADIDO_LOGIN", $cookies.get('GRADIDO_LOGIN')) - //this.$store.dispatch('accountBalance') - //console.log("STORE login() to " + state.is_auth) - router.push('/KontoOverview') - - } - - return true - }, (error) => { - console.log(error); - }); - //console.log("STORE login() from" + state.is_auth) - //if (state.is_auth) { - // state.is_auth = false - // state.active = false - //} else { - // state.is_auth = true - // state.active = true - //} - // console.log("STORE login() to " + state.is_auth) - }, - creatUser( state, formdata) { - //console.log("Im Store creatUser() start " ) - axios.post("http://localhost/login_api/createUser", formdata).then((ldata) => { - - console.log("Im Store creatUser() axios then ", ldata); - // this.ldata = ldata.data; - router.push('/Login') - - }, (error) => { - console.log(error); - }); - }, - logout(state){ - axios.post("http://localhost/login_api/logout", {"session_id": state.session_id}).then((ldata) => { - - //console.log("Im Store logout() axios then ", ldata); - // this.ldata = ldata.data; - //return true - state.is_auth = false - state.is_admin = false - state.active = false - state.session_id = '' - state.user.email = '' - $cookies.set('gdd_is_auth','false'); - $cookies.remove('gdd_u'); - $cookies.remove('gdd_session_id'); - router.push('/Login') - }, (error) => { - console.log(error); - }); - - }, - ajaxCreate(state){ - state.ajaxCreateData.session_id = state.session_id - console.log(" state.ajaxCreateData => ", state.ajaxCreateData) - axios.post(" http://localhost/transaction-creations/ajaxCreate/", state.ajaxCreateData).then((req) => { - console.log("ajaxCreate => ", req) - }, (error) => { - console.log(error); - }); - }, - ajaxListTransactions(state) { - console.log("ajaxListTransactions => START") - axios.get("http://localhost/state-balances/ajaxListTransactions/"+ state.session_id).then((req) => { - console.log("ajaxListTransactions => ", req) - }, (error) => { - console.log(error); - }); - }, - accountBalance(state) { - console.log(" => START") - state.url = "http://localhost/state-balances/ajaxGetBalance/"+ state.session_id - console.log(state.url) - axios.get(state.url).then((req) => { - console.log("accountBalance => ", req.data.balance) - state.user.balance = req.data.balance - }, (error) => { - console.log(error); - }); - } -*/ \ No newline at end of file +}) \ No newline at end of file