roboto-js 1.1.7 → 1.1.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/rbt_api.cjs +60 -46
- package/dist/esm/rbt_api.js +60 -46
- package/package.json +1 -1
- package/src/rbt_api.js +30 -14
package/dist/cjs/rbt_api.cjs
CHANGED
|
@@ -107,21 +107,22 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
107
107
|
return _context2.abrupt("return", this._handleError(response));
|
|
108
108
|
case 7:
|
|
109
109
|
this.iac_session = response.data;
|
|
110
|
+
this.currentUser = this.iac_session ? new _rbt_user["default"](this.iac_session.user, this.axios) : null;
|
|
110
111
|
// update axios instance headers with authtoken
|
|
111
112
|
this.axios.defaults.headers.common['authtoken'] = response.data.authToken;
|
|
112
113
|
if (typeof localStorage != 'undefined') {
|
|
113
114
|
localStorage.setItem('authtoken', response.data.authToken);
|
|
114
115
|
}
|
|
115
116
|
return _context2.abrupt("return", response.data);
|
|
116
|
-
case
|
|
117
|
-
_context2.prev =
|
|
117
|
+
case 14:
|
|
118
|
+
_context2.prev = 14;
|
|
118
119
|
_context2.t0 = _context2["catch"](0);
|
|
119
120
|
this._handleError(_context2.t0);
|
|
120
|
-
case
|
|
121
|
+
case 17:
|
|
121
122
|
case "end":
|
|
122
123
|
return _context2.stop();
|
|
123
124
|
}
|
|
124
|
-
}, _callee2, this, [[0,
|
|
125
|
+
}, _callee2, this, [[0, 14]]);
|
|
125
126
|
}));
|
|
126
127
|
function login(_x) {
|
|
127
128
|
return _login.apply(this, arguments);
|
|
@@ -149,6 +150,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
149
150
|
case 6:
|
|
150
151
|
// Clear the iac_session and remove the auth token from axios headers
|
|
151
152
|
this.iac_session = null;
|
|
153
|
+
this.currentUser = null;
|
|
152
154
|
if (this.axios.defaults.headers.common['authtoken']) {
|
|
153
155
|
delete this.axios.defaults.headers.common['authtoken'];
|
|
154
156
|
}
|
|
@@ -160,15 +162,15 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
160
162
|
|
|
161
163
|
// Return some kind of success response or the response from the server
|
|
162
164
|
return _context3.abrupt("return", response.data);
|
|
163
|
-
case
|
|
164
|
-
_context3.prev =
|
|
165
|
+
case 13:
|
|
166
|
+
_context3.prev = 13;
|
|
165
167
|
_context3.t0 = _context3["catch"](0);
|
|
166
168
|
this._handleError(_context3.t0);
|
|
167
|
-
case
|
|
169
|
+
case 16:
|
|
168
170
|
case "end":
|
|
169
171
|
return _context3.stop();
|
|
170
172
|
}
|
|
171
|
-
}, _callee3, this, [[0,
|
|
173
|
+
}, _callee3, this, [[0, 13]]);
|
|
172
174
|
}));
|
|
173
175
|
function logout() {
|
|
174
176
|
return _logout.apply(this, arguments);
|
|
@@ -179,34 +181,42 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
179
181
|
key: "loadCurrentUser",
|
|
180
182
|
value: function () {
|
|
181
183
|
var _loadCurrentUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
182
|
-
var
|
|
184
|
+
var response;
|
|
183
185
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
184
186
|
while (1) switch (_context4.prev = _context4.next) {
|
|
185
187
|
case 0:
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
_context4.
|
|
192
|
-
|
|
193
|
-
|
|
188
|
+
_context4.prev = 0;
|
|
189
|
+
if (!this.currentUser) {
|
|
190
|
+
_context4.next = 3;
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
return _context4.abrupt("return", this.currentUser);
|
|
194
|
+
case 3:
|
|
195
|
+
if (!this.authtoken) {
|
|
196
|
+
_context4.next = 10;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
_context4.next = 6;
|
|
200
|
+
return this.refreshAuthToken(this.authtoken);
|
|
201
|
+
case 6:
|
|
194
202
|
response = _context4.sent;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
id: userData.id
|
|
203
|
+
this.currentUser = new _rbt_user["default"]({
|
|
204
|
+
id: response.user.id
|
|
198
205
|
}, this.axios);
|
|
199
|
-
|
|
200
|
-
return _context4.abrupt("return",
|
|
201
|
-
case
|
|
202
|
-
|
|
203
|
-
_context4.
|
|
204
|
-
return _context4.abrupt("return", this._handleError(_context4.t0));
|
|
206
|
+
this.currentUser.setData(response.user);
|
|
207
|
+
return _context4.abrupt("return", this.currentUser);
|
|
208
|
+
case 10:
|
|
209
|
+
this.currentUser = null;
|
|
210
|
+
return _context4.abrupt("return", null);
|
|
205
211
|
case 14:
|
|
212
|
+
_context4.prev = 14;
|
|
213
|
+
_context4.t0 = _context4["catch"](0);
|
|
214
|
+
return _context4.abrupt("return", this._handleError(_context4.t0));
|
|
215
|
+
case 17:
|
|
206
216
|
case "end":
|
|
207
217
|
return _context4.stop();
|
|
208
218
|
}
|
|
209
|
-
}, _callee4, this, [[
|
|
219
|
+
}, _callee4, this, [[0, 14]]);
|
|
210
220
|
}));
|
|
211
221
|
function loadCurrentUser() {
|
|
212
222
|
return _loadCurrentUser.apply(this, arguments);
|
|
@@ -221,26 +231,30 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
221
231
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
222
232
|
while (1) switch (_context5.prev = _context5.next) {
|
|
223
233
|
case 0:
|
|
224
|
-
debugger;
|
|
225
234
|
params = {
|
|
226
235
|
emailConfirmCode: confirmCode
|
|
227
236
|
};
|
|
228
|
-
_context5.prev =
|
|
229
|
-
_context5.next =
|
|
237
|
+
_context5.prev = 1;
|
|
238
|
+
_context5.next = 4;
|
|
230
239
|
return this.axios.post('/user_service/confirmUserEmail', [params]);
|
|
231
|
-
case
|
|
240
|
+
case 4:
|
|
232
241
|
response = _context5.sent;
|
|
233
|
-
|
|
234
|
-
|
|
242
|
+
if (!(response.data.ok === false)) {
|
|
243
|
+
_context5.next = 7;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
return _context5.abrupt("return", this._handleError(response));
|
|
247
|
+
case 7:
|
|
248
|
+
return _context5.abrupt("return", response.data);
|
|
235
249
|
case 10:
|
|
236
250
|
_context5.prev = 10;
|
|
237
|
-
_context5.t0 = _context5["catch"](
|
|
251
|
+
_context5.t0 = _context5["catch"](1);
|
|
238
252
|
return _context5.abrupt("return", this._handleError(_context5.t0));
|
|
239
253
|
case 13:
|
|
240
254
|
case "end":
|
|
241
255
|
return _context5.stop();
|
|
242
256
|
}
|
|
243
|
-
}, _callee5, this, [[
|
|
257
|
+
}, _callee5, this, [[1, 10]]);
|
|
244
258
|
}));
|
|
245
259
|
function confirmUserEmail(_x2) {
|
|
246
260
|
return _confirmUserEmail.apply(this, arguments);
|
|
@@ -251,7 +265,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
251
265
|
key: "loadUser",
|
|
252
266
|
value: function () {
|
|
253
267
|
var _loadUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(userId) {
|
|
254
|
-
var params, _response$
|
|
268
|
+
var params, _response$data, response, userData, User;
|
|
255
269
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
256
270
|
while (1) switch (_context6.prev = _context6.next) {
|
|
257
271
|
case 0:
|
|
@@ -263,7 +277,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
263
277
|
return this.axios.post('/user_service/loadUser', [params]);
|
|
264
278
|
case 4:
|
|
265
279
|
response = _context6.sent;
|
|
266
|
-
userData = response === null || response === void 0 || (_response$
|
|
280
|
+
userData = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.user;
|
|
267
281
|
User = new _rbt_user["default"]({
|
|
268
282
|
id: userData.id
|
|
269
283
|
}, this.axios);
|
|
@@ -297,16 +311,17 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
297
311
|
return this.axios.post('/user_service/refreshAuthToken', [authtoken]);
|
|
298
312
|
case 3:
|
|
299
313
|
response = _context7.sent;
|
|
314
|
+
debugger;
|
|
300
315
|
return _context7.abrupt("return", response.data);
|
|
301
|
-
case
|
|
302
|
-
_context7.prev =
|
|
316
|
+
case 8:
|
|
317
|
+
_context7.prev = 8;
|
|
303
318
|
_context7.t0 = _context7["catch"](0);
|
|
304
319
|
this._handleError(_context7.t0);
|
|
305
|
-
case
|
|
320
|
+
case 11:
|
|
306
321
|
case "end":
|
|
307
322
|
return _context7.stop();
|
|
308
323
|
}
|
|
309
|
-
}, _callee7, this, [[0,
|
|
324
|
+
}, _callee7, this, [[0, 8]]);
|
|
310
325
|
}));
|
|
311
326
|
function refreshAuthToken(_x4) {
|
|
312
327
|
return _refreshAuthToken.apply(this, arguments);
|
|
@@ -337,19 +352,18 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
337
352
|
return this.axios.post('/user_service/registerUser', [dataHash]);
|
|
338
353
|
case 4:
|
|
339
354
|
response = _context8.sent;
|
|
340
|
-
debugger;
|
|
341
355
|
record = response.data;
|
|
342
356
|
return _context8.abrupt("return", new _rbt_user["default"](record, this.axios));
|
|
343
|
-
case
|
|
344
|
-
_context8.prev =
|
|
357
|
+
case 9:
|
|
358
|
+
_context8.prev = 9;
|
|
345
359
|
_context8.t0 = _context8["catch"](1);
|
|
346
360
|
debugger;
|
|
347
361
|
return _context8.abrupt("return", this._handleError(_context8.t0));
|
|
348
|
-
case
|
|
362
|
+
case 13:
|
|
349
363
|
case "end":
|
|
350
364
|
return _context8.stop();
|
|
351
365
|
}
|
|
352
|
-
}, _callee8, this, [[1,
|
|
366
|
+
}, _callee8, this, [[1, 9]]);
|
|
353
367
|
}));
|
|
354
368
|
function registerUser() {
|
|
355
369
|
return _registerUser.apply(this, arguments);
|
package/dist/esm/rbt_api.js
CHANGED
|
@@ -107,21 +107,22 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
107
107
|
return _context2.abrupt("return", this._handleError(response));
|
|
108
108
|
case 7:
|
|
109
109
|
this.iac_session = response.data;
|
|
110
|
+
this.currentUser = this.iac_session ? new _rbt_user["default"](this.iac_session.user, this.axios) : null;
|
|
110
111
|
// update axios instance headers with authtoken
|
|
111
112
|
this.axios.defaults.headers.common['authtoken'] = response.data.authToken;
|
|
112
113
|
if (typeof localStorage != 'undefined') {
|
|
113
114
|
localStorage.setItem('authtoken', response.data.authToken);
|
|
114
115
|
}
|
|
115
116
|
return _context2.abrupt("return", response.data);
|
|
116
|
-
case
|
|
117
|
-
_context2.prev =
|
|
117
|
+
case 14:
|
|
118
|
+
_context2.prev = 14;
|
|
118
119
|
_context2.t0 = _context2["catch"](0);
|
|
119
120
|
this._handleError(_context2.t0);
|
|
120
|
-
case
|
|
121
|
+
case 17:
|
|
121
122
|
case "end":
|
|
122
123
|
return _context2.stop();
|
|
123
124
|
}
|
|
124
|
-
}, _callee2, this, [[0,
|
|
125
|
+
}, _callee2, this, [[0, 14]]);
|
|
125
126
|
}));
|
|
126
127
|
function login(_x) {
|
|
127
128
|
return _login.apply(this, arguments);
|
|
@@ -149,6 +150,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
149
150
|
case 6:
|
|
150
151
|
// Clear the iac_session and remove the auth token from axios headers
|
|
151
152
|
this.iac_session = null;
|
|
153
|
+
this.currentUser = null;
|
|
152
154
|
if (this.axios.defaults.headers.common['authtoken']) {
|
|
153
155
|
delete this.axios.defaults.headers.common['authtoken'];
|
|
154
156
|
}
|
|
@@ -160,15 +162,15 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
160
162
|
|
|
161
163
|
// Return some kind of success response or the response from the server
|
|
162
164
|
return _context3.abrupt("return", response.data);
|
|
163
|
-
case
|
|
164
|
-
_context3.prev =
|
|
165
|
+
case 13:
|
|
166
|
+
_context3.prev = 13;
|
|
165
167
|
_context3.t0 = _context3["catch"](0);
|
|
166
168
|
this._handleError(_context3.t0);
|
|
167
|
-
case
|
|
169
|
+
case 16:
|
|
168
170
|
case "end":
|
|
169
171
|
return _context3.stop();
|
|
170
172
|
}
|
|
171
|
-
}, _callee3, this, [[0,
|
|
173
|
+
}, _callee3, this, [[0, 13]]);
|
|
172
174
|
}));
|
|
173
175
|
function logout() {
|
|
174
176
|
return _logout.apply(this, arguments);
|
|
@@ -179,34 +181,42 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
179
181
|
key: "loadCurrentUser",
|
|
180
182
|
value: function () {
|
|
181
183
|
var _loadCurrentUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
182
|
-
var
|
|
184
|
+
var response;
|
|
183
185
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
184
186
|
while (1) switch (_context4.prev = _context4.next) {
|
|
185
187
|
case 0:
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
_context4.
|
|
192
|
-
|
|
193
|
-
|
|
188
|
+
_context4.prev = 0;
|
|
189
|
+
if (!this.currentUser) {
|
|
190
|
+
_context4.next = 3;
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
return _context4.abrupt("return", this.currentUser);
|
|
194
|
+
case 3:
|
|
195
|
+
if (!this.authtoken) {
|
|
196
|
+
_context4.next = 10;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
_context4.next = 6;
|
|
200
|
+
return this.refreshAuthToken(this.authtoken);
|
|
201
|
+
case 6:
|
|
194
202
|
response = _context4.sent;
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
id: userData.id
|
|
203
|
+
this.currentUser = new _rbt_user["default"]({
|
|
204
|
+
id: response.user.id
|
|
198
205
|
}, this.axios);
|
|
199
|
-
|
|
200
|
-
return _context4.abrupt("return",
|
|
201
|
-
case
|
|
202
|
-
|
|
203
|
-
_context4.
|
|
204
|
-
return _context4.abrupt("return", this._handleError(_context4.t0));
|
|
206
|
+
this.currentUser.setData(response.user);
|
|
207
|
+
return _context4.abrupt("return", this.currentUser);
|
|
208
|
+
case 10:
|
|
209
|
+
this.currentUser = null;
|
|
210
|
+
return _context4.abrupt("return", null);
|
|
205
211
|
case 14:
|
|
212
|
+
_context4.prev = 14;
|
|
213
|
+
_context4.t0 = _context4["catch"](0);
|
|
214
|
+
return _context4.abrupt("return", this._handleError(_context4.t0));
|
|
215
|
+
case 17:
|
|
206
216
|
case "end":
|
|
207
217
|
return _context4.stop();
|
|
208
218
|
}
|
|
209
|
-
}, _callee4, this, [[
|
|
219
|
+
}, _callee4, this, [[0, 14]]);
|
|
210
220
|
}));
|
|
211
221
|
function loadCurrentUser() {
|
|
212
222
|
return _loadCurrentUser.apply(this, arguments);
|
|
@@ -221,26 +231,30 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
221
231
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
222
232
|
while (1) switch (_context5.prev = _context5.next) {
|
|
223
233
|
case 0:
|
|
224
|
-
debugger;
|
|
225
234
|
params = {
|
|
226
235
|
emailConfirmCode: confirmCode
|
|
227
236
|
};
|
|
228
|
-
_context5.prev =
|
|
229
|
-
_context5.next =
|
|
237
|
+
_context5.prev = 1;
|
|
238
|
+
_context5.next = 4;
|
|
230
239
|
return this.axios.post('/user_service/confirmUserEmail', [params]);
|
|
231
|
-
case
|
|
240
|
+
case 4:
|
|
232
241
|
response = _context5.sent;
|
|
233
|
-
|
|
234
|
-
|
|
242
|
+
if (!(response.data.ok === false)) {
|
|
243
|
+
_context5.next = 7;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
246
|
+
return _context5.abrupt("return", this._handleError(response));
|
|
247
|
+
case 7:
|
|
248
|
+
return _context5.abrupt("return", response.data);
|
|
235
249
|
case 10:
|
|
236
250
|
_context5.prev = 10;
|
|
237
|
-
_context5.t0 = _context5["catch"](
|
|
251
|
+
_context5.t0 = _context5["catch"](1);
|
|
238
252
|
return _context5.abrupt("return", this._handleError(_context5.t0));
|
|
239
253
|
case 13:
|
|
240
254
|
case "end":
|
|
241
255
|
return _context5.stop();
|
|
242
256
|
}
|
|
243
|
-
}, _callee5, this, [[
|
|
257
|
+
}, _callee5, this, [[1, 10]]);
|
|
244
258
|
}));
|
|
245
259
|
function confirmUserEmail(_x2) {
|
|
246
260
|
return _confirmUserEmail.apply(this, arguments);
|
|
@@ -251,7 +265,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
251
265
|
key: "loadUser",
|
|
252
266
|
value: function () {
|
|
253
267
|
var _loadUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(userId) {
|
|
254
|
-
var params, _response$
|
|
268
|
+
var params, _response$data, response, userData, User;
|
|
255
269
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
256
270
|
while (1) switch (_context6.prev = _context6.next) {
|
|
257
271
|
case 0:
|
|
@@ -263,7 +277,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
263
277
|
return this.axios.post('/user_service/loadUser', [params]);
|
|
264
278
|
case 4:
|
|
265
279
|
response = _context6.sent;
|
|
266
|
-
userData = response === null || response === void 0 || (_response$
|
|
280
|
+
userData = response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.user;
|
|
267
281
|
User = new _rbt_user["default"]({
|
|
268
282
|
id: userData.id
|
|
269
283
|
}, this.axios);
|
|
@@ -297,16 +311,17 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
297
311
|
return this.axios.post('/user_service/refreshAuthToken', [authtoken]);
|
|
298
312
|
case 3:
|
|
299
313
|
response = _context7.sent;
|
|
314
|
+
debugger;
|
|
300
315
|
return _context7.abrupt("return", response.data);
|
|
301
|
-
case
|
|
302
|
-
_context7.prev =
|
|
316
|
+
case 8:
|
|
317
|
+
_context7.prev = 8;
|
|
303
318
|
_context7.t0 = _context7["catch"](0);
|
|
304
319
|
this._handleError(_context7.t0);
|
|
305
|
-
case
|
|
320
|
+
case 11:
|
|
306
321
|
case "end":
|
|
307
322
|
return _context7.stop();
|
|
308
323
|
}
|
|
309
|
-
}, _callee7, this, [[0,
|
|
324
|
+
}, _callee7, this, [[0, 8]]);
|
|
310
325
|
}));
|
|
311
326
|
function refreshAuthToken(_x4) {
|
|
312
327
|
return _refreshAuthToken.apply(this, arguments);
|
|
@@ -337,19 +352,18 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
|
|
|
337
352
|
return this.axios.post('/user_service/registerUser', [dataHash]);
|
|
338
353
|
case 4:
|
|
339
354
|
response = _context8.sent;
|
|
340
|
-
debugger;
|
|
341
355
|
record = response.data;
|
|
342
356
|
return _context8.abrupt("return", new _rbt_user["default"](record, this.axios));
|
|
343
|
-
case
|
|
344
|
-
_context8.prev =
|
|
357
|
+
case 9:
|
|
358
|
+
_context8.prev = 9;
|
|
345
359
|
_context8.t0 = _context8["catch"](1);
|
|
346
360
|
debugger;
|
|
347
361
|
return _context8.abrupt("return", this._handleError(_context8.t0));
|
|
348
|
-
case
|
|
362
|
+
case 13:
|
|
349
363
|
case "end":
|
|
350
364
|
return _context8.stop();
|
|
351
365
|
}
|
|
352
|
-
}, _callee8, this, [[1,
|
|
366
|
+
}, _callee8, this, [[1, 9]]);
|
|
353
367
|
}));
|
|
354
368
|
function registerUser() {
|
|
355
369
|
return _registerUser.apply(this, arguments);
|
package/package.json
CHANGED
package/src/rbt_api.js
CHANGED
|
@@ -61,6 +61,7 @@ export default class RbtApi {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
this.iac_session = response.data;
|
|
64
|
+
this.currentUser = (this.iac_session)? new RbtUser(this.iac_session.user, this.axios): null;
|
|
64
65
|
// update axios instance headers with authtoken
|
|
65
66
|
this.axios.defaults.headers.common['authtoken'] = response.data.authToken;
|
|
66
67
|
|
|
@@ -87,6 +88,7 @@ export default class RbtApi {
|
|
|
87
88
|
|
|
88
89
|
// Clear the iac_session and remove the auth token from axios headers
|
|
89
90
|
this.iac_session = null;
|
|
91
|
+
this.currentUser = null;
|
|
90
92
|
if (this.axios.defaults.headers.common['authtoken']) {
|
|
91
93
|
delete this.axios.defaults.headers.common['authtoken'];
|
|
92
94
|
}
|
|
@@ -105,19 +107,29 @@ export default class RbtApi {
|
|
|
105
107
|
|
|
106
108
|
async loadCurrentUser(){
|
|
107
109
|
|
|
108
|
-
// TODO - get the actual user from the session
|
|
109
|
-
let params = { id: 'superuser_tom' };
|
|
110
|
-
|
|
111
110
|
try {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
|
|
112
|
+
if(this.currentUser){
|
|
113
|
+
return this.currentUser;
|
|
114
|
+
}
|
|
115
115
|
|
|
116
|
-
|
|
117
|
-
User.setData(userData);
|
|
118
|
-
return User;
|
|
116
|
+
if(this.authtoken){
|
|
119
117
|
|
|
120
|
-
|
|
118
|
+
let response = await this.refreshAuthToken(this.authtoken);
|
|
119
|
+
this.currentUser = new RbtUser({ id: response.user.id }, this.axios);
|
|
120
|
+
this.currentUser.setData(response.user);
|
|
121
|
+
return this.currentUser;
|
|
122
|
+
|
|
123
|
+
//this.currentOrg = new RbtObject(response.organization, this.axios);
|
|
124
|
+
//this.currentOrg.type = '<@iac.organization>';
|
|
125
|
+
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
this.currentUser = null;
|
|
129
|
+
return null;
|
|
130
|
+
|
|
131
|
+
}
|
|
132
|
+
catch(e){
|
|
121
133
|
return this._handleError(e);
|
|
122
134
|
}
|
|
123
135
|
|
|
@@ -126,14 +138,17 @@ export default class RbtApi {
|
|
|
126
138
|
|
|
127
139
|
async confirmUserEmail(confirmCode){
|
|
128
140
|
|
|
129
|
-
debugger;
|
|
130
141
|
let params = { emailConfirmCode: confirmCode };
|
|
131
142
|
|
|
132
143
|
try {
|
|
133
144
|
|
|
134
145
|
const response = await this.axios.post('/user_service/confirmUserEmail', [params]);
|
|
135
|
-
|
|
136
|
-
|
|
146
|
+
|
|
147
|
+
if (response.data.ok === false) {
|
|
148
|
+
return this._handleError(response);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return response.data;
|
|
137
152
|
|
|
138
153
|
} catch (e) {
|
|
139
154
|
return this._handleError(e);
|
|
@@ -167,6 +182,8 @@ export default class RbtApi {
|
|
|
167
182
|
try {
|
|
168
183
|
|
|
169
184
|
const response = await this.axios.post('/user_service/refreshAuthToken', [authtoken]);
|
|
185
|
+
|
|
186
|
+
debugger;
|
|
170
187
|
return response.data;
|
|
171
188
|
|
|
172
189
|
} catch (e) {
|
|
@@ -187,7 +204,6 @@ export default class RbtApi {
|
|
|
187
204
|
try {
|
|
188
205
|
const response = await this.axios.post('/user_service/registerUser', [dataHash]);
|
|
189
206
|
|
|
190
|
-
debugger;
|
|
191
207
|
const record = response.data;
|
|
192
208
|
return new RbtUser(record, this.axios);
|
|
193
209
|
} catch (e) {
|