@c8y/login 1023.22.6 → 1023.22.11

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": "1023.22.6",
3
+ "version": "1023.22.11",
4
4
  "description": "This package is used to scaffold a login application for Cumulocity IoT.",
5
5
  "dependencies": {
6
- "@c8y/style": "1023.22.6",
7
- "@c8y/ngx-components": "1023.22.6",
8
- "@c8y/client": "1023.22.6",
9
- "@c8y/bootstrap": "1023.22.6",
6
+ "@c8y/style": "1023.22.11",
7
+ "@c8y/ngx-components": "1023.22.11",
8
+ "@c8y/client": "1023.22.11",
9
+ "@c8y/bootstrap": "1023.22.11",
10
10
  "@angular/cdk": "^20.2.14",
11
11
  "monaco-editor": "~0.53.0",
12
12
  "ngx-bootstrap": "20.0.2",
13
13
  "rxjs": "7.8.2"
14
14
  },
15
15
  "devDependencies": {
16
- "@c8y/options": "1023.22.6",
17
- "@c8y/devkit": "1023.22.6"
16
+ "@c8y/options": "1023.22.11",
17
+ "@c8y/devkit": "1023.22.11"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "@angular/common": ">=20 <21"
@@ -37,7 +37,6 @@ import {
37
37
  export class LoginService extends SimplifiedAuthService {
38
38
  rememberMe = false;
39
39
  loginMode: ITenantLoginOption;
40
- managementLoginMode: ITenantLoginOption;
41
40
  oauthOptions: ITenantLoginOption;
42
41
  isFirstLogin = true;
43
42
  automaticLoginInProgress$ = new BehaviorSubject(true);
@@ -435,7 +434,7 @@ export class LoginService extends SimplifiedAuthService {
435
434
  * @param credentials The credentials for that login
436
435
  */
437
436
  async switchLoginMode(credentials?: ICredentials) {
438
- const isPasswordGrantLogin = await this.isPasswordGrantLogin(credentials);
437
+ const isPasswordGrantLogin = await this.isPasswordGrantLogin();
439
438
  if (isPasswordGrantLogin && credentials) {
440
439
  const res = await this.generateOauthToken(credentials);
441
440
  if (!res?.ok) {
@@ -454,7 +453,7 @@ export class LoginService extends SimplifiedAuthService {
454
453
  }
455
454
 
456
455
  async generateOauthToken(credentials?: ICredentials): Promise<IFetchResponse | null> {
457
- if ((await this.isPasswordGrantLogin(credentials)) && credentials) {
456
+ if ((await this.isPasswordGrantLogin()) && credentials) {
458
457
  const params = new URLSearchParams({
459
458
  grant_type: 'PASSWORD',
460
459
  username: credentials.user,
@@ -473,17 +472,8 @@ export class LoginService extends SimplifiedAuthService {
473
472
  return null;
474
473
  }
475
474
 
476
- async isPasswordGrantLogin(credentials?: ICredentials) {
477
- let loginMode = this.loginMode;
478
-
479
- if (this.isSupportUser(credentials)) {
480
- if (!this.managementLoginMode) {
481
- this.managementLoginMode = await this.getManagementLoginMode();
482
- }
483
- loginMode = this.managementLoginMode;
484
- }
485
-
486
- return this.tenantUiService.isOauthInternal(loginMode);
475
+ async isPasswordGrantLogin() {
476
+ return this.tenantUiService.isOauthInternal(this.loginMode);
487
477
  }
488
478
 
489
479
  /**
@@ -688,11 +678,6 @@ export class LoginService extends SimplifiedAuthService {
688
678
  : `tenant/oauth`;
689
679
  }
690
680
 
691
- private async getManagementLoginMode() {
692
- const managementLoginOptions = (await this.tenantLoginOptionsService.listForManagement()).data;
693
- return this.tenantUiService.getPreferredLoginOption(managementLoginOptions);
694
- }
695
-
696
681
  private async handleErrorStatusCodes(response: IFetchResponse): Promise<IFetchResponse> {
697
682
  if (response.status >= 400) {
698
683
  const data = await response.json();
@@ -1,47 +1,62 @@
1
- <form #twoFactorForm="ngForm" class="loginForm" (ngSubmit)="verifyTFACode()" novalidate>
2
- <div class="legend form-block center" translate>Two-factor authentication</div>
1
+ <form
2
+ class="loginForm"
3
+ #twoFactorForm="ngForm"
4
+ (ngSubmit)="verifyTFACode()"
5
+ novalidate
6
+ >
7
+ <div
8
+ class="legend form-block center"
9
+ translate
10
+ >
11
+ Two-factor authentication
12
+ </div>
3
13
 
4
14
  <c8y-form-group>
5
15
  <label translate>Verification code</label>
6
16
  <input
7
- [(ngModel)]="model.smsToken"
8
- #sms_token="ngModel"
9
- type="text"
17
+ class="form-control"
18
+ placeholder="{{ 'e.g.' | translate }} 624327"
10
19
  name="sms_token"
20
+ type="text"
11
21
  autofocus
22
+ required
23
+ [(ngModel)]="model.smsToken"
24
+ #sms_token="ngModel"
12
25
  autocapitalize="off"
13
26
  autocorrect="off"
14
- class="form-control"
15
- placeholder="{{ 'e.g.' | translate }} 624327"
16
- required
17
27
  />
18
- <p *ngIf="!twoFactorForm.form.valid || isLoading" class="help-block" translate>
19
- Insert the code received via SMS.
20
- </p>
28
+ @if (!twoFactorForm.form.valid || isLoading) {
29
+ <p
30
+ class="help-block"
31
+ translate
32
+ >
33
+ Insert the code received via SMS.
34
+ </p>
35
+ }
21
36
  </c8y-form-group>
22
37
 
23
38
  <button
39
+ class="btn btn-primary btn-lg btn-block form-group"
24
40
  title="{{ 'Verify' | translate }}"
25
41
  [disabled]="!twoFactorForm.form.valid || isLoading"
26
- class="btn btn-primary btn-lg btn-block form-group"
27
42
  >
28
43
  {{ 'Verify' | translate }}
29
44
  </button>
30
45
 
31
46
  <div class="d-flex m-t-8 j-c-center">
32
47
  <button
33
- type="button"
48
+ class="btn btn-link btn-sm"
34
49
  title="{{ 'Send new code' | translate }}"
50
+ type="button"
35
51
  [ngClass]="{ disabled: isLoading }"
36
- class="btn btn-link btn-sm"
37
52
  (click)="resendTFASms()"
38
53
  >
39
54
  {{ 'Send new code' | translate }}
40
55
  </button>
41
56
  <button
42
- type="button"
43
- title="{{ 'Log in' | translate }}"
44
57
  class="btn btn-link btn-sm"
58
+ title="{{ 'Log in' | translate }}"
59
+ type="button"
45
60
  (click)="onCancel.emit()"
46
61
  >
47
62
  {{ 'Log in' | translate }}
@@ -11,7 +11,7 @@ import {
11
11
  } from '@c8y/ngx-components';
12
12
  import { gettext } from '@c8y/ngx-components/gettext';
13
13
  import { FormsModule } from '@angular/forms';
14
- import { NgIf, NgClass } from '@angular/common';
14
+ import { NgClass } from '@angular/common';
15
15
  import { LoginEvent, LoginViews } from '../login.model';
16
16
 
17
17
  @Component({
@@ -24,7 +24,6 @@ import { LoginEvent, LoginViews } from '../login.model';
24
24
  C8yTranslateDirective,
25
25
  FormGroupComponent,
26
26
  RequiredInputPlaceholderDirective,
27
- NgIf,
28
27
  NgClass,
29
28
  C8yTranslatePipe
30
29
  ]
@@ -75,7 +74,7 @@ export class SmsChallengeComponent {
75
74
  }
76
75
 
77
76
  private async usesOAuthInternal() {
78
- return this.loginService.isPasswordGrantLogin(this.credentials);
77
+ return this.loginService.isPasswordGrantLogin();
79
78
  }
80
79
 
81
80
  private async verifyCodeWithOauth() {