roboto-js 1.4.43 → 1.4.44

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.
@@ -335,7 +335,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
335
335
  key: "loadCurrentUser",
336
336
  value: function () {
337
337
  var _loadCurrentUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
338
- var _response$user, response;
338
+ var response, _response$user;
339
339
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
340
340
  while (1) switch (_context7.prev = _context7.next) {
341
341
  case 0:
@@ -347,7 +347,7 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
347
347
  return _context7.abrupt("return", this.currentUser);
348
348
  case 3:
349
349
  if (!this.authtoken) {
350
- _context7.next = 12;
350
+ _context7.next = 13;
351
351
  break;
352
352
  }
353
353
  _context7.next = 6;
@@ -360,23 +360,26 @@ var RbtApi = exports["default"] = /*#__PURE__*/function () {
360
360
  }
361
361
  return _context7.abrupt("return", null);
362
362
  case 9:
363
- this.currentUser = new _rbt_user["default"]({
364
- id: response === null || response === void 0 || (_response$user = response.user) === null || _response$user === void 0 ? void 0 : _response$user.id
365
- }, this.axios);
366
- this.currentUser.setData(response.user);
363
+ if (response !== null && response !== void 0 && response.user) {
364
+ this.currentUser = new _rbt_user["default"]({
365
+ id: response === null || response === void 0 || (_response$user = response.user) === null || _response$user === void 0 ? void 0 : _response$user.id
366
+ }, this.axios);
367
+ this.currentUser.setData(response.user);
368
+ }
367
369
  return _context7.abrupt("return", this.currentUser);
368
- case 12:
370
+ case 13:
369
371
  this.currentUser = null;
372
+ case 14:
370
373
  return _context7.abrupt("return", null);
371
- case 16:
372
- _context7.prev = 16;
374
+ case 17:
375
+ _context7.prev = 17;
373
376
  _context7.t0 = _context7["catch"](0);
374
377
  return _context7.abrupt("return", this._handleError(_context7.t0));
375
- case 19:
378
+ case 20:
376
379
  case "end":
377
380
  return _context7.stop();
378
381
  }
379
- }, _callee7, this, [[0, 16]]);
382
+ }, _callee7, this, [[0, 17]]);
380
383
  }));
381
384
  function loadCurrentUser() {
382
385
  return _loadCurrentUser.apply(this, arguments);
@@ -167,16 +167,18 @@ export default class RbtApi {
167
167
  if (this.authtoken) {
168
168
  let response = await this.refreshAuthToken(this.authtoken);
169
169
  if (!response) return null;
170
- this.currentUser = new RbtUser({
171
- id: response?.user?.id
172
- }, this.axios);
173
- this.currentUser.setData(response.user);
170
+ if (response?.user) {
171
+ this.currentUser = new RbtUser({
172
+ id: response?.user?.id
173
+ }, this.axios);
174
+ this.currentUser.setData(response.user);
175
+ }
174
176
  return this.currentUser;
175
-
176
177
  //this.currentOrg = new RbtObject(response.organization, this.axios);
177
178
  //this.currentOrg.type = '<@iac.organization>';
179
+ } else {
180
+ this.currentUser = null;
178
181
  }
179
- this.currentUser = null;
180
182
  return null;
181
183
  } catch (e) {
182
184
  return this._handleError(e);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "roboto-js",
3
- "version": "1.4.43",
3
+ "version": "1.4.44",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "main": "dist/cjs/index.cjs",
package/src/rbt_api.js CHANGED
@@ -208,16 +208,21 @@ export default class RbtApi {
208
208
  let response = await this.refreshAuthToken(this.authtoken);
209
209
  if(!response) return null;
210
210
 
211
- this.currentUser = new RbtUser({ id: response?.user?.id }, this.axios);
212
- this.currentUser.setData(response.user);
213
- return this.currentUser;
211
+ if(response?.user){
212
+
213
+ this.currentUser = new RbtUser({ id: response?.user?.id }, this.axios);
214
+ this.currentUser.setData(response.user);
215
+
216
+ }
214
217
 
218
+ return this.currentUser;
215
219
  //this.currentOrg = new RbtObject(response.organization, this.axios);
216
220
  //this.currentOrg.type = '<@iac.organization>';
217
221
 
218
222
  }
219
-
220
- this.currentUser = null;
223
+ else{
224
+ this.currentUser = null;
225
+ }
221
226
  return null;
222
227
 
223
228
  }