diff --git a/src/main.js b/src/main.js index 3264630..7008cf2 100644 --- a/src/main.js +++ b/src/main.js @@ -46,7 +46,6 @@ class hasura { return this; } - setProject (name) { this.projectConfig.baseDomain = name + '.hasura-app.io'; this.resetFetch(); @@ -69,6 +68,21 @@ class hasura { this.saveUser(); } + setUserInfo(userInfo) { + this.user = { + ...this.user, + id: userInfo.hasura_id, + roles: userInfo.hasura_roles, + token: userInfo.auth_token, + }; + + ['username', 'email', 'mobile'].map(x => { + this.user[x] = userInfo[x] ? userInfo[x] : this.user[x]; + }); + + this.saveUser(); + } + saveUser() { localStorage.setItem('hasura.user', JSON.stringify(this.user)); this.resetFetch();