Skip to content

Commit

Permalink
Adds setUserInfo method for login with custom API.
Browse files Browse the repository at this point in the history
  • Loading branch information
coco98 committed Jun 29, 2017
1 parent 807dcbb commit 3c6c121
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class hasura {
return this;
}


setProject (name) {
this.projectConfig.baseDomain = name + '.hasura-app.io';
this.resetFetch();
Expand All @@ -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();
Expand Down

0 comments on commit 3c6c121

Please sign in to comment.