Skip to content

Commit ea87f65

Browse files
committed
PD-4790 fix validators
1 parent c38c80f commit ea87f65

3 files changed

Lines changed: 10 additions & 19 deletions

File tree

‎projects/orcid-registry-ui/src/lib/components/auth-challenge/auth-challenge.component.html‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ <h1 class="orc-font-heading-small text-center font-normal" i18n>
284284
type="submit"
285285
class="row orc-font-body mat-elevation-z0 text-center h-10! mb-6 block w-full"
286286
i18n
287-
[disabled]="isSubmitDisabled"
288-
[ngClass]="{ 'verify-button-loading': isSubmitDisabled }"
287+
[disabled]="loading || parentForm.invalid"
288+
[ngClass]="{ 'verify-button-loading': loading || parentForm.invalid }"
289289
>
290290
Verify my account and continue
291291
</button>

‎projects/orcid-registry-ui/src/lib/components/auth-challenge/auth-challenge.component.scss‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
:host {
2+
font-family: var(--orcid-font-family-sans, 'Noto Sans', sans-serif);
3+
}
4+
15
.grow {
26
flex-grow: 1;
37
}

‎projects/orcid-registry-ui/src/lib/components/auth-challenge/auth-challenge.component.ts‎

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,10 @@ export class AuthChallengeComponent implements OnInit, OnDestroy {
141141
this.data.recoveryControlName
142142
)
143143

144-
if (this.showRecoveryCode) {
144+
if (!this.data.showTwoFactorField) {
145+
twoFactorCodeControl?.removeValidators(Validators.required)
146+
recoveryCodeControl?.removeValidators(Validators.required)
147+
} else if (this.showRecoveryCode) {
145148
twoFactorCodeControl?.removeValidators(Validators.required)
146149
recoveryCodeControl?.addValidators(Validators.required)
147150
} else {
@@ -153,22 +156,6 @@ export class AuthChallengeComponent implements OnInit, OnDestroy {
153156
recoveryCodeControl?.updateValueAndValidity()
154157
}
155158

156-
get isSubmitDisabled(): boolean {
157-
if (this.loading || !this.parentForm) {
158-
return true
159-
}
160-
161-
const activeControlName = this.showRecoveryCode
162-
? this.data.recoveryControlName
163-
: this.data.codeControlName
164-
165-
const activeControl = this.parentForm.get(activeControlName)
166-
167-
return (
168-
this.parentForm.invalid || activeControl?.invalid || !activeControl?.value
169-
)
170-
}
171-
172159
processBackendResponse(value: any) {
173160
this.loading = false
174161

0 commit comments

Comments
 (0)