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/cjs/index.cjs +131 -112
- package/dist/cjs/rbt_api.cjs +291 -243
- package/dist/esm/index.js +3 -0
- package/dist/esm/rbt_api.js +20 -0
- package/package.json +1 -1
- package/src/index.js +3 -0
- package/src/rbt_api.js +29 -0
package/dist/esm/index.js
CHANGED
package/dist/esm/rbt_api.js
CHANGED
|
@@ -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
package/src/index.js
CHANGED
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.
|