@sumaris-net/ngx-components 2.4.82-rc2 → 2.4.82-rc4

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.
@@ -11688,11 +11688,10 @@ const environment = Object.freeze({
11688
11688
  helpUrl: 'https://gitlab.ifremer.fr/sih-public/sumaris/sumaris-doc/-/blob/master/user-manual/index_fr.md',
11689
11689
  // Development
11690
11690
  defaultAuthValues: {
11691
- // Basic auth (using Person.username)
11692
- // username: 'admq2', password: 'q22006'
11693
- // Token auth (using Person.pubkey)
11694
- //username: 'admin@sumaris.net', password: 'admin',
11695
- username: 'benoit.lavenier@e-is.pro', password: 'priezPourMoi!',
11691
+ // Basic auth (using Person.username)
11692
+ // username: 'admq2', password: 'q22006'
11693
+ // Token auth (using Person.pubkey)
11694
+ //username: 'admin@sumaris.net', password: 'admin',
11696
11695
  },
11697
11696
  account: {
11698
11697
  enableListenChanges: true,
@@ -18225,6 +18224,7 @@ class AccountService extends BaseGraphqlService {
18225
18224
  });
18226
18225
  }
18227
18226
  restoreLocally() {
18227
+ var _a;
18228
18228
  return __awaiter(this, void 0, void 0, function* () {
18229
18229
  // Restore from storage
18230
18230
  const values = yield Promise.all([
@@ -18232,9 +18232,14 @@ class AccountService extends BaseGraphqlService {
18232
18232
  this.storage.get(TOKEN_STORAGE_KEY),
18233
18233
  this.storage.get(SECKEY_STORAGE_KEY)
18234
18234
  ]);
18235
- const pubkey = values[0];
18236
- const token = values[1];
18235
+ let pubkey = values[0];
18236
+ let token = values[1];
18237
18237
  const seckey = values[2];
18238
+ // DEV only - auth by token
18239
+ if (!this.environment.production && ((_a = this.environment.defaultAuthValues) === null || _a === void 0 ? void 0 : _a.token)) {
18240
+ token = token || this.environment.defaultAuthValues.token;
18241
+ pubkey = pubkey || (token === null || token === void 0 ? void 0 : token.split(':', 2)[0]);
18242
+ }
18238
18243
  // Quit if no pubkey (not logged)
18239
18244
  if (!pubkey)
18240
18245
  return;
@@ -18280,8 +18285,16 @@ class AccountService extends BaseGraphqlService {
18280
18285
  jsonAccount = accountStr && ((typeof accountStr === 'string') && JSON.parse(jsonAccount) || accountStr);
18281
18286
  }
18282
18287
  // Invalid account: do not use it
18283
- if (!jsonAccount || jsonAccount.pubkey !== pubkey)
18284
- return;
18288
+ if (!jsonAccount || jsonAccount.pubkey !== pubkey) {
18289
+ // DEV only: create a fake account with given username
18290
+ if (!this.environment.production && this.environment.defaultAuthValues.username) {
18291
+ const username = this.environment.defaultAuthValues.username;
18292
+ jsonAccount = { pubkey, username, firstName: username, lastName: username };
18293
+ }
18294
+ else {
18295
+ return;
18296
+ }
18297
+ }
18285
18298
  // Transform to entity
18286
18299
  const account = Account.fromObject(jsonAccount);
18287
18300
  // Update data