feat(accounts): add accounts and shared accounts call
This commit is contained in:
@@ -2,6 +2,9 @@
|
|||||||
"name": "noscomptes",
|
"name": "noscomptes",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
"engines": {
|
||||||
|
"node" : "16.13.0"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"serve": "vue-cli-service serve",
|
"serve": "vue-cli-service serve",
|
||||||
"build": "vue-cli-service build",
|
"build": "vue-cli-service build",
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import router from '@/router/router'
|
import router from '@/router/router'
|
||||||
import {logWithGoogle} from '@/config/noscomptes'
|
import {logWithGoogle, getAccounts, getSharedAccounts} from '@/config/noscomptes'
|
||||||
export default {
|
export default {
|
||||||
name: 'login_signup_social',
|
name: 'login_signup_social',
|
||||||
mounted () {
|
mounted () {
|
||||||
@@ -19,18 +19,27 @@ export default {
|
|||||||
this.$gAuth
|
this.$gAuth
|
||||||
.signIn()
|
.signIn()
|
||||||
.then(GoogleUser => {
|
.then(GoogleUser => {
|
||||||
logWithGoogle(GoogleUser.getAuthResponse().id_token)
|
return logWithGoogle(GoogleUser.getAuthResponse().id_token).then(data => {
|
||||||
// on success do something
|
let userInfoMapped = {
|
||||||
console.log('GoogleUser', GoogleUser)
|
nosComptesId: data.id,
|
||||||
let userInfoMapped = {
|
googleId: GoogleUser.wa,
|
||||||
googleId: GoogleUser.wa,
|
firstName: GoogleUser.mt.Re,
|
||||||
firstName: GoogleUser.mt.Re,
|
email: data.email,
|
||||||
email: GoogleUser.mt.Xt,
|
oauth_token: GoogleUser.getAuthResponse().id_token,
|
||||||
oauth_token: GoogleUser.Zb.access_token,
|
}
|
||||||
}
|
this.$store.commit('setLoginUser', userInfoMapped)
|
||||||
this.$store.commit('setLoginUser', userInfoMapped)
|
return userInfoMapped
|
||||||
router.push('/')
|
|
||||||
})
|
})})
|
||||||
|
.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 => {
|
.catch(error => {
|
||||||
console.log('error', error)
|
console.log('error', error)
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,15 +1,32 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
|
|
||||||
export const logWithGoogle = (oauthToken) => {
|
export const logWithGoogle = (oauthToken) => {
|
||||||
const headers = {
|
const headers = {
|
||||||
"Authorization": "Bearer "+oauthToken
|
"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) => {
|
export const getAccounts = (oauthToken, userId) => {
|
||||||
const headers = {
|
const headers = {
|
||||||
"Authorization": "Bearer "+oauthToken
|
"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)
|
setStore('user', user)
|
||||||
},
|
},
|
||||||
deleteLoginUser(state) {
|
deleteLoginUser(state) {
|
||||||
console.log("delete user")
|
|
||||||
state.loggedUser = undefined
|
state.loggedUser = undefined
|
||||||
removeItem('user')
|
removeItem('user')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user