roboto-js 1.4.5 → 1.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -69,6 +69,9 @@ export default class Roboto {
69
69
  async login(params) {
70
70
  return this.api.login(params);
71
71
  }
72
+ async loginWithOauth(params) {
73
+ return this.api.loginWithOauth(params);
74
+ }
72
75
  async logout() {
73
76
  return this.api.logout();
74
77
  }
@@ -88,7 +88,27 @@ export default class RbtApi {
88
88
  if (this.localStorageAdaptor) {
89
89
  await this.localStorageAdaptor.setItem('authtoken', response.data.authToken);
90
90
  }
91
- return this.currentUser;
91
+ return response.data;
92
+ } catch (e) {
93
+ this._handleError(e);
94
+ }
95
+ }
96
+ async loginWithOauth(userData) {
97
+ try {
98
+ debugger;
99
+ const response = await this.post('/registerOrSigninOauth', userData);
100
+ if (response.data.ok === false) {
101
+ return this._handleError(response);
102
+ }
103
+ this.iac_session = response.data;
104
+ this.currentUser = this.iac_session ? new RbtUser(this.iac_session.user, this.axios) : null;
105
+ // update axios instance headers with authtoken
106
+ this.axios.defaults.headers.common['authtoken'] = response.data.authToken;
107
+ this.authtoken = response.data.authToken;
108
+ if (this.localStorageAdaptor) {
109
+ await this.localStorageAdaptor.setItem('authtoken', response.data.authToken);
110
+ }
111
+ return response.data;
92
112
  } catch (e) {
93
113
  this._handleError(e);
94
114
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.4.5",
3
+ "version": "1.4.7",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/index.js CHANGED
@@ -85,6 +85,9 @@ export default class Roboto{
85
85
  async login(params){
86
86
  return this.api.login(params);
87
87
  }
88
+ async loginWithOauth(params){
89
+ return this.api.loginWithOauth(params);
90
+ }
88
91
  async logout(){
89
92
  return this.api.logout();
90
93
  }
package/src/rbt_api.js CHANGED
@@ -103,12 +103,41 @@ export default class RbtApi {
103
103
  await this.localStorageAdaptor.setItem('authtoken', response.data.authToken);
104
104
  }
105
105
 
106
- return this.currentUser;
106
+ return response.data;
107
+
108
+ } catch (e) {
109
+
110
+ this._handleError(e);
111
+ }
112
+ }
107
113
 
114
+ async loginWithOauth(userData){
115
+
116
+ try {
117
+ debugger;
118
+ const response = await this.post('/registerOrSigninOauth', userData );
119
+
120
+ if (response.data.ok === false) {
121
+ return this._handleError(response);
122
+ }
123
+
124
+ this.iac_session = response.data;
125
+ this.currentUser = (this.iac_session)? new RbtUser(this.iac_session.user, this.axios): null;
126
+ // update axios instance headers with authtoken
127
+ this.axios.defaults.headers.common['authtoken'] = response.data.authToken;
128
+ this.authtoken = response.data.authToken;
129
+
130
+ if(this.localStorageAdaptor){
131
+ await this.localStorageAdaptor.setItem('authtoken', response.data.authToken);
132
+ }
133
+
134
+ return response.data;
135
+
108
136
  } catch (e) {
109
137
 
110
138
  this._handleError(e);
111
139
  }
140
+
112
141
  }
113
142
 
114
143
  async logout() {