feat(accounts): add accounts and shared accounts call

This commit is contained in:
2021-11-04 02:04:59 +01:00
parent e3f2e12df4
commit a169862311
5 changed files with 53 additions and 20 deletions

View File

@@ -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)
})