@c8y/login 1022.34.0 → 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 +7 -7
- package/src/app/login/login.service.ts +32 -9
- package/tsconfig.app.json +1 -0
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@c8y/login",
|
|
3
|
-
"version": "1022.
|
|
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.
|
|
7
|
-
"@c8y/ngx-components": "1022.
|
|
8
|
-
"@c8y/client": "1022.
|
|
9
|
-
"@c8y/bootstrap": "1022.
|
|
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.
|
|
17
|
-
"@c8y/devkit": "1022.
|
|
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
|
-
|
|
293
|
-
|
|
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(
|
|
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
|
-
|
|
402
|
-
|
|
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 });
|