From 0befc2650783091d168efd3759b3522ae2f1cf61 Mon Sep 17 00:00:00 2001 From: Ken Sternberg <133134217+kensternberg-authentik@users.noreply.github.com> Date: Mon, 13 Jan 2025 10:56:37 -0800 Subject: [PATCH] web: fix error handling bug in ApplicationWizard.RACProviderForm (#12640) * web: Add InvalidationFlow to Radius Provider dialogues ## What - Bugfix: adds the InvalidationFlow to the Radius Provider dialogues - Repairs: `{"invalidation_flow":["This field is required."]}` message, which was *not* propagated to the Notification. - Nitpick: Pretties `?foo=${true}` expressions: `s/\?([^=]+)=\$\{true\}/\1/` ## Note Yes, I know I'm going to have to do more magic when we harmonize the forms, and no, I didn't add the Property Mappings to the wizard, and yes, I know I'm going to have pain with the *new* version of the wizard. But this is a serious bug; you can't make Radius servers with *either* of the current dialogues at the moment. * This (temporary) change is needed to prevent the unit tests from failing. \# What \# Why \# How \# Designs \# Test Steps \# Other Notes * Revert "This (temporary) change is needed to prevent the unit tests from failing." This reverts commit dddde09be571a639ecd041569dd3a282aab3f9be. * web: fix error handling bug in ui # What When I converted all of the Provider forms over to a unified structure, the RAC form stood out as one that couldn't be directly converted, so two copies were retained. The error handling was updated to a new format, but this one bit of older handling was missed. For now, we're going back to using `Record` for errors, to stay as close to the `./admin/providers/` style of handling. # Testing This error prevented the RAC Provider form from loading in the wizard. Seeing that it works in the wizard should be sufficient. --- .../steps/providers/ApplicationWizardProviderForm.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web/src/admin/applications/wizard/steps/providers/ApplicationWizardProviderForm.ts b/web/src/admin/applications/wizard/steps/providers/ApplicationWizardProviderForm.ts index 0a08773ed4..350029f21b 100644 --- a/web/src/admin/applications/wizard/steps/providers/ApplicationWizardProviderForm.ts +++ b/web/src/admin/applications/wizard/steps/providers/ApplicationWizardProviderForm.ts @@ -25,7 +25,7 @@ export class ApplicationWizardProviderForm extends AKEl wizard!: ApplicationWizardState; @property({ type: Object, attribute: false }) - errors: Map = new Map(); + errors: Record = {}; @query("form#providerform") form!: HTMLFormElement; @@ -41,13 +41,13 @@ export class ApplicationWizardProviderForm extends AKEl } get valid() { - this.errors = new Map(); + this.errors = {}; return this.form.checkValidity(); } errorMessages(name: string) { - return this.errors.has(name) - ? [this.errors.get(name)] + return name in this.errors + ? [this.errors[name]] : (this.wizard.errors?.provider?.[name] ?? this.wizard.errors?.provider?.[camelToSnake(name)] ?? []); @@ -56,7 +56,7 @@ export class ApplicationWizardProviderForm extends AKEl isValid(name: keyof T) { return !( (this.wizard.errors?.provider?.[name as string] ?? []).length > 0 || - this.errors.has(name) + this.errors?.[name] !== undefined ); } }