feat(accounts): add accounts and shared accounts call
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
|
||||
<script>
|
||||
import router from '@/router/router'
|
||||
import {logWithGoogle} from '@/config/noscomptes'
|
||||
import {logWithGoogle, getAccounts, getSharedAccounts} from '@/config/noscomptes'
|
||||
export default {
|
||||
name: 'login_signup_social',
|
||||
mounted () {
|
||||
@@ -19,18 +19,27 @@ export default {
|
||||
this.$gAuth
|
||||
.signIn()
|
||||
.then(GoogleUser => {
|
||||
logWithGoogle(GoogleUser.getAuthResponse().id_token)
|
||||
// on success do something
|
||||
console.log('GoogleUser', GoogleUser)
|
||||
let userInfoMapped = {
|
||||
googleId: GoogleUser.wa,
|
||||
firstName: GoogleUser.mt.Re,
|
||||
email: GoogleUser.mt.Xt,
|
||||
oauth_token: GoogleUser.Zb.access_token,
|
||||
}
|
||||
this.$store.commit('setLoginUser', userInfoMapped)
|
||||
router.push('/')
|
||||
})
|
||||
return logWithGoogle(GoogleUser.getAuthResponse().id_token).then(data => {
|
||||
let userInfoMapped = {
|
||||
nosComptesId: data.id,
|
||||
googleId: GoogleUser.wa,
|
||||
firstName: GoogleUser.mt.Re,
|
||||
email: data.email,
|
||||
oauth_token: GoogleUser.getAuthResponse().id_token,
|
||||
}
|
||||
this.$store.commit('setLoginUser', userInfoMapped)
|
||||
return userInfoMapped
|
||||
|
||||
})})
|
||||
.then(userInfo => {
|
||||
getAccounts(userInfo.oauth_token, userInfo.nosComptesId).then(data => {
|
||||
this.$store.commit('userAccounts', data)
|
||||
})
|
||||
getSharedAccounts(userInfo.oauth_token, userInfo.nosComptesId).then(data => {
|
||||
this.$store.commit('userSharedAccounts', data)
|
||||
})
|
||||
router.push('/')
|
||||
})
|
||||
.catch(error => {
|
||||
console.log('error', error)
|
||||
})
|
||||
|
||||
@@ -1,15 +1,32 @@
|
||||
import Vue from 'vue'
|
||||
|
||||
export const logWithGoogle = (oauthToken) => {
|
||||
const headers = {
|
||||
const headers = {
|
||||
"Authorization": "Bearer "+oauthToken
|
||||
};
|
||||
return Vue.axios.post("http://localhost:8081/users", "{}",{headers})
|
||||
return Vue.axios.get("http://localhost:8081/users",{headers}).then(response => {return response.data})
|
||||
}
|
||||
|
||||
export const getUserInformation = (oauthToken) => {
|
||||
const headers = {
|
||||
export const getAccounts = (oauthToken, userId) => {
|
||||
const headers = {
|
||||
"Authorization": "Bearer "+oauthToken
|
||||
};
|
||||
return Vue.axios.get("http://localhost:8081/configuration", {headers})
|
||||
};
|
||||
return Vue.axios.get("http://localhost:8081/users/"+userId+"/accountsgc", {headers}).then(response => {console.log(response);return response.data})
|
||||
}
|
||||
|
||||
export const getSharedAccounts = (oauthToken, userId) => {
|
||||
const headers = {
|
||||
"Authorization": "Bearer "+oauthToken
|
||||
};
|
||||
return Vue.axios.get("http://localhost:8081/users/"+userId+"/sharedaccounts", {headers}).then(response => {console.log(response);return response.data})
|
||||
}
|
||||
|
||||
export const createAccount = (oauthToken, userId, account) => {
|
||||
const headers = {
|
||||
"Authorization": "Bearer " + oauthToken
|
||||
};
|
||||
return Vue.axios.post("http://localhost:8081/configuration", account, {headers}).then(response => {
|
||||
console.log(response);
|
||||
return response.data
|
||||
})
|
||||
}
|
||||
|
||||
5
src/dto/Account.js
Normal file
5
src/dto/Account.js
Normal file
@@ -0,0 +1,5 @@
|
||||
class Account {
|
||||
constructor(name) {
|
||||
this.name = name
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,6 @@ export default new Vuex.Store({
|
||||
setStore('user', user)
|
||||
},
|
||||
deleteLoginUser(state) {
|
||||
console.log("delete user")
|
||||
state.loggedUser = undefined
|
||||
removeItem('user')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user