@c8y/login 1022.35.1 → 1022.44.3

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/package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "name": "@c8y/login",
3
- "version": "1022.35.1",
3
+ "version": "1022.44.3",
4
4
  "description": "This package is used to scaffold a login application for Cumulocity IoT.",
5
5
  "dependencies": {
6
- "@c8y/style": "1022.35.1",
7
- "@c8y/ngx-components": "1022.35.1",
8
- "@c8y/client": "1022.35.1",
9
- "@c8y/bootstrap": "1022.35.1",
6
+ "@c8y/style": "1022.44.3",
7
+ "@c8y/ngx-components": "1022.44.3",
8
+ "@c8y/client": "1022.44.3",
9
+ "@c8y/bootstrap": "1022.44.3",
10
10
  "@angular/cdk": "^19.2.19",
11
11
  "monaco-editor": "~0.52.2",
12
12
  "ngx-bootstrap": "19.0.2",
13
13
  "rxjs": "7.8.1"
14
14
  },
15
15
  "devDependencies": {
16
- "@c8y/options": "1022.35.1",
17
- "@c8y/devkit": "1022.35.1"
16
+ "@c8y/options": "1022.44.3",
17
+ "@c8y/devkit": "1022.44.3"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "@angular/common": ">=19 <20"
@@ -8,10 +8,11 @@ import {
8
8
  ICurrentTenant,
9
9
  IFetchResponse,
10
10
  ITenantLoginOption,
11
- IUser,
12
11
  TenantLoginOptionsService,
13
12
  TenantService,
14
- UserService
13
+ UserService,
14
+ ICurrentUser,
15
+ IUser
15
16
  } from '@c8y/client';
16
17
  import { TenantUiService, ModalService, Status, SimplifiedAuthService } from '@c8y/ngx-components';
17
18
  import { gettext } from '@c8y/ngx-components/gettext';
@@ -289,8 +290,18 @@ export class LoginService extends SimplifiedAuthService {
289
290
  auth = this.cookieAuth;
290
291
  }
291
292
 
292
- const userRes = await this.user.current();
293
- const user = userRes.data;
293
+ let user: ICurrentUser | IUser;
294
+ try {
295
+ const { data } = await this.user.current();
296
+ user = data;
297
+ } catch (e) {
298
+ if (e.res?.status === 403) {
299
+ const { data } = await this.user.currentWithEffectiveRoles();
300
+ user = data;
301
+ } else {
302
+ throw e;
303
+ }
304
+ }
294
305
 
295
306
  const supportUserName = this.getSupportUserName(credentials);
296
307
  const token = this.setCredentials(
@@ -310,7 +321,7 @@ export class LoginService extends SimplifiedAuthService {
310
321
  return this.ensureUserPermissionsForRedirect(user);
311
322
  }
312
323
 
313
- async ensureUserPermissionsForRedirect(user: IUser) {
324
+ async ensureUserPermissionsForRedirect(user: IUser | ICurrentUser) {
314
325
  const redirectPath = await this.getRedirectPath();
315
326
  if (!redirectPath) {
316
327
  return false;
@@ -358,7 +369,10 @@ export class LoginService extends SimplifiedAuthService {
358
369
  return matches ? matches[0] : null;
359
370
  }
360
371
 
361
- async userHasAccessToApp(user: IUser, redirectPath: string): Promise<false | string> {
372
+ async userHasAccessToApp(
373
+ user: IUser | ICurrentUser,
374
+ redirectPath: string
375
+ ): Promise<false | string> {
362
376
  if (!redirectPath) {
363
377
  return false;
364
378
  }
@@ -390,7 +404,7 @@ export class LoginService extends SimplifiedAuthService {
390
404
  * @param user The current user object.
391
405
  * @param supportUserName The current support user name.
392
406
  */
393
- async authFulfilled(tenant?: ICurrentTenant, user?: IUser) {
407
+ async authFulfilled(tenant?: ICurrentTenant, user?: ICurrentUser | IUser) {
394
408
  if (!tenant) {
395
409
  const { data } = await this.tenant.current({ withParent: true });
396
410
  tenant = data;
@@ -398,8 +412,17 @@ export class LoginService extends SimplifiedAuthService {
398
412
  }
399
413
 
400
414
  if (!user) {
401
- const { data } = await this.user.current();
402
- user = data;
415
+ try {
416
+ const { data } = await this.user.current();
417
+ user = data;
418
+ } catch (e) {
419
+ if (e.res?.status === 403) {
420
+ const { data } = await this.user.currentWithEffectiveRoles();
421
+ user = data;
422
+ } else {
423
+ throw e;
424
+ }
425
+ }
403
426
  }
404
427
 
405
428
  this.ui.setUser({ user });
package/tsconfig.app.json CHANGED
@@ -16,5 +16,6 @@
16
16
  "exclude": [
17
17
  "src/**/*.spec.ts",
18
18
  "../ngx-components/dist",
19
+ "../ngx-components/**/*.spec.ts",
19
20
  ]
20
21
  }