Browse Source

UI: Fixed validation

pull/6235/head
Vladyslav_Prykhodko 4 years ago
parent
commit
da058ccfc1
  1. 2
      common/data/src/main/java/org/thingsboard/server/common/data/security/model/mfa/PlatformTwoFaSettings.java
  2. 5
      ui-ngx/src/app/modules/home/pages/admin/two-factor-auth-settings.component.html
  3. 4
      ui-ngx/src/app/modules/home/pages/admin/two-factor-auth-settings.component.scss
  4. 4
      ui-ngx/src/app/modules/home/pages/admin/two-factor-auth-settings.component.ts
  5. 3
      ui-ngx/src/app/modules/home/pages/security/security.component.ts
  6. 3
      ui-ngx/src/app/modules/login/pages/login/two-factor-auth-login.component.ts
  7. 2
      ui-ngx/src/assets/locale/locale.constant-en_US.json

2
common/data/src/main/java/org/thingsboard/server/common/data/security/model/mfa/PlatformTwoFaSettings.java

@ -41,7 +41,7 @@ public class PlatformTwoFaSettings {
private String verificationCodeCheckRateLimit;
@Min(value = 0, message = "maximum number of verification failure before user lockout must be positive")
private Integer maxVerificationFailuresBeforeUserLockout;
@Min(value = 1, message = "total amount of time allotted for verification must be greater than 0")
@Min(value = 60, message = "total amount of time allotted for verification must be greater than or equal 60")
private Integer totalAllowedTimeForVerification;

5
ui-ngx/src/app/modules/home/pages/admin/two-factor-auth-settings.component.html

@ -51,7 +51,8 @@
<mat-form-field fxFlex class="mat-block">
<mat-label translate>admin.2fa.issuer-name</mat-label>
<input matInput formControlName="issuerName" required>
<mat-error *ngIf="provider.get('issuerName').hasError('required')">
<mat-error *ngIf="provider.get('issuerName').hasError('required') ||
provider.get('issuerName').hasError('pattern')">
{{ "admin.2fa.issuer-name-required" | translate }}
</mat-error>
</mat-form-field>
@ -118,7 +119,7 @@
<div class="input-row" fxLayout="row" fxLayout.xs="column" fxLayoutGap.gt-xs="8px">
<mat-form-field fxFlex class="mat-block">
<mat-label translate>admin.2fa.total-allowed-time-for-verification</mat-label>
<input matInput required formControlName="totalAllowedTimeForVerification" type="number" step="1" min="1">
<input matInput required formControlName="totalAllowedTimeForVerification" type="number" step="1" min="60">
<mat-error *ngIf="twoFaFormGroup.get('totalAllowedTimeForVerification').hasError('required')">
{{ 'admin.2fa.total-allowed-time-for-verification-required' | translate }}
</mat-error>

4
ui-ngx/src/app/modules/home/pages/admin/two-factor-auth-settings.component.scss

@ -73,6 +73,10 @@
:host ::ng-deep {
.mat-expansion-panel {
.mat-expansion-panel-content {
font-size: 16px;
}
&.provider {
.mat-expansion-panel-header > .mat-content {
overflow: inherit;

4
ui-ngx/src/app/modules/home/pages/admin/two-factor-auth-settings.component.ts

@ -122,7 +122,7 @@ export class TwoFactorAuthSettingsComponent extends PageComponent implements OnI
]],
totalAllowedTimeForVerification: [3600, [
Validators.required,
Validators.min(1),
Validators.min(60),
Validators.pattern(/^\d*$/)
]],
verificationCodeCheckRateLimitEnable: [false],
@ -192,7 +192,7 @@ export class TwoFactorAuthSettingsComponent extends PageComponent implements OnI
};
switch (provider) {
case TwoFactorAuthProviderType.TOTP:
formControlConfig.issuerName = [{value: 'ThingsBoard', disabled: true}, Validators.required];
formControlConfig.issuerName = [{value: 'ThingsBoard', disabled: true}, [Validators.required, Validators.pattern(/^\S+$/)]];
break;
case TwoFactorAuthProviderType.SMS:
formControlConfig.smsVerificationMessageTemplate = [{value: 'Verification code: ${code}', disabled: true}, [

3
ui-ngx/src/app/modules/home/pages/security/security.component.ts

@ -170,6 +170,9 @@ export class SecurityComponent extends PageComponent implements OnInit, OnDestro
confirm2FAChange(event: MouseEvent, provider: TwoFactorAuthProviderType) {
event.stopPropagation();
event.preventDefault();
if (this.twoFactorAuth.get(provider).disabled) {
return;
}
if (this.twoFactorAuth.get(provider).value) {
const providerName = this.translate.instant(`security.2fa.provider.${provider.toLowerCase()}`);
this.dialogService.confirm(

3
ui-ngx/src/app/modules/login/pages/login/two-factor-auth-login.component.ts

@ -169,10 +169,11 @@ export class TwoFactorAuthLoginComponent extends PageComponent implements OnInit
$event.stopPropagation();
}
this.hideResendButton = true;
this.countDownTime = 0;
this.twoFactorAuthService.requestTwoFaVerificationCodeSend(this.selectedProvider).subscribe(() => {
this.countDownTime = this.minVerificationPeriod;
}, () => {
this.countDownTime = 30;
this.countDownTime = this.minVerificationPeriod;
});
}

2
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -332,7 +332,7 @@
"retry-verification-code-period-pattern": "Minimal period time is 5 sec",
"retry-verification-code-period-required": "Retry verification code period is required.",
"total-allowed-time-for-verification": "Total allowed time for verification (sec)",
"total-allowed-time-for-verification-pattern": "Total allowed time must be a positive integer.",
"total-allowed-time-for-verification-pattern": "Minimal total allowed time is 60 sec",
"total-allowed-time-for-verification-required": "Total allowed time is required.",
"use-system-two-factor-auth-settings": "Use system two factor auth settings",
"verification-code-check-rate-limit": "Verification code check rate limit",

Loading…
Cancel
Save