|
| 1 | +@if (!showRecoveryCode) { |
| 2 | +<div class="input-container"> |
| 3 | + <mat-label |
| 4 | + class="orc-font-small-print" |
| 5 | + id="2fa-input-label" |
| 6 | + i18n="@@account.twoPassword" |
| 7 | + [ngClass]="{ |
| 8 | + error: twoFactorCodeWasTouched && parentForm.get(codeControlName).invalid |
| 9 | + }" |
| 10 | + > |
| 11 | + Two-factor authentication |
| 12 | + </mat-label> |
| 13 | + <mat-form-field |
| 14 | + appearance="outline" |
| 15 | + [hideRequiredMarker]="true" |
| 16 | + class="no-hint" |
| 17 | + > |
| 18 | + <input |
| 19 | + id="twoFactorCode" |
| 20 | + type="text" |
| 21 | + inputmode="numeric" |
| 22 | + aria-labelledby="2fa-input-label" |
| 23 | + [formControlName]="codeControlName" |
| 24 | + matInput |
| 25 | + #twoFactorCodeInput |
| 26 | + [errorStateMatcher]="errorMatcher" |
| 27 | + [ngClass]="{ |
| 28 | + error: |
| 29 | + twoFactorCodeWasTouched && parentForm.get(codeControlName).invalid |
| 30 | + }" |
| 31 | + /> |
| 32 | + </mat-form-field> |
| 33 | + <div class="two-factor-description orc-font-small-print"> |
| 34 | + <div class="two-factor-description-text"> |
| 35 | + @if (!parentForm.get(codeControlName).invalid || !twoFactorCodeWasTouched) |
| 36 | + { |
| 37 | + <mat-hint i18n="@@account.enterTheCode"> |
| 38 | + Enter the code from your two-factor authentication app |
| 39 | + </mat-hint> |
| 40 | + } |
| 41 | + <mat-error |
| 42 | + *ngIf="parentForm.get(codeControlName).hasError('backendInvalid')" |
| 43 | + > |
| 44 | + <p |
| 45 | + i18n="@@ngOrcid.signin.2fa.badVerificationCode" |
| 46 | + class="error-message" |
| 47 | + > |
| 48 | + Invalid authentication code |
| 49 | + </p> |
| 50 | + </mat-error> |
| 51 | + <mat-error |
| 52 | + *ngIf=" |
| 53 | + twoFactorCodeWasTouched && |
| 54 | + parentForm.get(codeControlName).hasError('required') |
| 55 | + " |
| 56 | + > |
| 57 | + <p |
| 58 | + i18n="@@ngOrcid.signin.2fa.verificationCodeRequired" |
| 59 | + class="error-message" |
| 60 | + > |
| 61 | + Authentication code is required |
| 62 | + </p> |
| 63 | + </mat-error> |
| 64 | + <mat-error |
| 65 | + *ngIf=" |
| 66 | + twoFactorCodeWasTouched && |
| 67 | + (parentForm.get(codeControlName).hasError('minlength') || |
| 68 | + parentForm.get(codeControlName).hasError('maxlength')) |
| 69 | + " |
| 70 | + > |
| 71 | + <p |
| 72 | + i18n="@@ngOrcid.signin.2fa.badVerificationCodeLength" |
| 73 | + class="error-message" |
| 74 | + > |
| 75 | + Invalid authentication code length |
| 76 | + </p> |
| 77 | + </mat-error> |
| 78 | + </div> |
| 79 | + <mat-hint |
| 80 | + [ngClass]="{ |
| 81 | + error: |
| 82 | + twoFactorCodeWasTouched && parentForm.get(codeControlName).invalid |
| 83 | + }" |
| 84 | + class="two-factor-description-length" |
| 85 | + > |
| 86 | + {{ parentForm.get(codeControlName).value?.length || 0 }}/6 |
| 87 | + </mat-hint> |
| 88 | + </div> |
| 89 | +</div> |
| 90 | +} @else { |
| 91 | +<div class="input-container"> |
| 92 | + <mat-label |
| 93 | + class="orc-font-small-print" |
| 94 | + id="recovery-input-label" |
| 95 | + i18n="@@ngOrcid.signin.2fa.recoveryCode" |
| 96 | + [ngClass]="{ |
| 97 | + error: |
| 98 | + twoFactorRecoveryCodeWasTouched && |
| 99 | + parentForm.get(recoveryControlName).invalid |
| 100 | + }" |
| 101 | + > |
| 102 | + Recovery code |
| 103 | + </mat-label> |
| 104 | + <mat-form-field |
| 105 | + appearance="outline" |
| 106 | + [hideRequiredMarker]="true" |
| 107 | + class="no-hint" |
| 108 | + > |
| 109 | + <input |
| 110 | + id="twoFactorRecoveryCode" |
| 111 | + type="text" |
| 112 | + inputmode="numeric" |
| 113 | + aria-labelledby="recovery-input-label" |
| 114 | + [formControlName]="recoveryControlName" |
| 115 | + #twoFactorRecoveryCodeInput |
| 116 | + matInput |
| 117 | + [errorStateMatcher]="errorMatcher" |
| 118 | + [ngClass]="{ |
| 119 | + error: |
| 120 | + twoFactorRecoveryCodeWasTouched && |
| 121 | + parentForm.get(recoveryControlName).invalid |
| 122 | + }" |
| 123 | + /> |
| 124 | + </mat-form-field> |
| 125 | + <div class="two-factor-description orc-font-small-print"> |
| 126 | + <div class="two-factor-description-text"> |
| 127 | + @if (!parentForm.get(recoveryControlName).invalid || |
| 128 | + !twoFactorRecoveryCodeWasTouched) { |
| 129 | + <mat-hint i18n="@@ngOrcid.signin.2fa.noDevice2" |
| 130 | + >Enter a recovery code</mat-hint |
| 131 | + > |
| 132 | + } |
| 133 | + <mat-error |
| 134 | + *ngIf="parentForm.get(recoveryControlName).hasError('backendInvalid')" |
| 135 | + > |
| 136 | + <p i18n="@@ngOrcid.signin.2fa.badRecoveryCode" class="error-message"> |
| 137 | + Invalid recovery code |
| 138 | + </p> |
| 139 | + </mat-error> |
| 140 | + <mat-error |
| 141 | + *ngIf=" |
| 142 | + twoFactorRecoveryCodeWasTouched && |
| 143 | + parentForm.get(recoveryControlName).hasError('required') |
| 144 | + " |
| 145 | + > |
| 146 | + <p |
| 147 | + i18n="@@ngOrcid.signin.2fa.recoveryCodeRequired" |
| 148 | + class="error-message" |
| 149 | + > |
| 150 | + Recovery code is required |
| 151 | + </p> |
| 152 | + </mat-error> |
| 153 | + <mat-error |
| 154 | + *ngIf=" |
| 155 | + twoFactorRecoveryCodeWasTouched && |
| 156 | + (parentForm.get(recoveryControlName).hasError('minlength') || |
| 157 | + parentForm.get(recoveryControlName).hasError('maxlength')) |
| 158 | + " |
| 159 | + > |
| 160 | + <p |
| 161 | + i18n="@@ngOrcid.signin.2fa.badRecoveryCodeLength" |
| 162 | + class="error-message" |
| 163 | + > |
| 164 | + Invalid recovery code length |
| 165 | + </p> |
| 166 | + </mat-error> |
| 167 | + </div> |
| 168 | + <mat-hint |
| 169 | + [ngClass]="{ |
| 170 | + error: |
| 171 | + twoFactorRecoveryCodeWasTouched && |
| 172 | + parentForm.get(recoveryControlName).invalid |
| 173 | + }" |
| 174 | + class="two-factor-description-length" |
| 175 | + > |
| 176 | + {{ parentForm.get(recoveryControlName).value?.length || 0 }}/10 |
| 177 | + </mat-hint> |
| 178 | + </div> |
| 179 | +</div> |
| 180 | +} |
0 commit comments