roboto-js 1.4.6 → 1.4.8

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
  }
@@ -93,6 +93,26 @@ export default class RbtApi {
93
93
  this._handleError(e);
94
94
  }
95
95
  }
96
+ async loginWithOauth(userData) {
97
+ try {
98
+ debugger;
99
+ const response = await this.post('/registerOrSigninOauth', userData);
100
+ if (response.ok === false) {
101
+ return this._handleError(response);
102
+ }
103
+ this.iac_session = response;
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.authToken;
107
+ this.authtoken = response.authToken;
108
+ if (this.localStorageAdaptor) {
109
+ await this.localStorageAdaptor.setItem('authtoken', response.authToken);
110
+ }
111
+ return response;
112
+ } catch (e) {
113
+ this._handleError(e);
114
+ }
115
+ }
96
116
  async logout() {
97
117
  try {
98
118
  // Call logout endpoint if necessary. Here, I assume there's a '/user_service/logoutUser' endpoint.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.4.6",
3
+ "version": "1.4.8",
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
@@ -111,6 +111,35 @@ export default class RbtApi {
111
111
  }
112
112
  }
113
113
 
114
+ async loginWithOauth(userData){
115
+
116
+ try {
117
+ debugger;
118
+ const response = await this.post('/registerOrSigninOauth', userData );
119
+
120
+ if (response.ok === false) {
121
+ return this._handleError(response);
122
+ }
123
+
124
+ this.iac_session = response;
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.authToken;
128
+ this.authtoken = response.authToken;
129
+
130
+ if(this.localStorageAdaptor){
131
+ await this.localStorageAdaptor.setItem('authtoken', response.authToken);
132
+ }
133
+
134
+ return response;
135
+
136
+ } catch (e) {
137
+
138
+ this._handleError(e);
139
+ }
140
+
141
+ }
142
+
114
143
  async logout() {
115
144
  try {
116
145
  // Call logout endpoint if necessary. Here, I assume there's a '/user_service/logoutUser' endpoint.