diff --git a/authentik/sources/ldap/signals.py b/authentik/sources/ldap/signals.py index e4279d40f..81d8c692e 100644 --- a/authentik/sources/ldap/signals.py +++ b/authentik/sources/ldap/signals.py @@ -66,8 +66,8 @@ def ldap_sync_password(sender, user: User, password: str, **_): if not sources.exists(): return source = sources.first() - changer = LDAPPasswordChanger(source) try: + changer = LDAPPasswordChanger(source) changer.change_password(user, password) except LDAPOperationResult as exc: LOGGER.warning("failed to set LDAP password", exc=exc) diff --git a/web/src/admin/applications/ApplicationCheckAccessForm.ts b/web/src/admin/applications/ApplicationCheckAccessForm.ts index 7d74e8e8f..94c179487 100644 --- a/web/src/admin/applications/ApplicationCheckAccessForm.ts +++ b/web/src/admin/applications/ApplicationCheckAccessForm.ts @@ -115,9 +115,8 @@ export class ApplicationCheckAccessForm extends Form<{ forUser: number }> { `; } - renderForm(): TemplateResult { - return html`
- + renderInlineForm(): TemplateResult { + return html` => { const args: CoreUsersListRequest = { @@ -144,7 +143,6 @@ export class ApplicationCheckAccessForm extends Form<{ forUser: number }> { > - ${this.result ? this.renderResult() : html``} - `; + ${this.result ? this.renderResult() : html``}`; } } diff --git a/web/src/admin/crypto/CertificateGenerateForm.ts b/web/src/admin/crypto/CertificateGenerateForm.ts index 2a7bd69aa..b0b1a8402 100644 --- a/web/src/admin/crypto/CertificateGenerateForm.ts +++ b/web/src/admin/crypto/CertificateGenerateForm.ts @@ -21,9 +21,12 @@ export class CertificateKeyPairForm extends Form { }); } - renderForm(): TemplateResult { - return html`
- + renderInlineForm(): TemplateResult { + return html` @@ -38,7 +41,6 @@ export class CertificateKeyPairForm extends Form { ?required=${true} > - - `; +
`; } } diff --git a/web/src/admin/flows/FlowImportForm.ts b/web/src/admin/flows/FlowImportForm.ts index 099ac8632..d2d2c3ebb 100644 --- a/web/src/admin/flows/FlowImportForm.ts +++ b/web/src/admin/flows/FlowImportForm.ts @@ -87,15 +87,13 @@ export class FlowImportForm extends Form { `; } - renderForm(): TemplateResult { - return html`
- + renderInlineForm(): TemplateResult { + return html`

${t`.yaml files, which can be found on goauthentik.io and can be exported by authentik.`}

- ${this.result ? this.renderResult() : html``} - `; + ${this.result ? this.renderResult() : html``}`; } } diff --git a/web/src/admin/groups/RelatedGroupList.ts b/web/src/admin/groups/RelatedGroupList.ts index fb2429979..ca752ef09 100644 --- a/web/src/admin/groups/RelatedGroupList.ts +++ b/web/src/admin/groups/RelatedGroupList.ts @@ -46,41 +46,39 @@ export class RelatedGroupAdd extends Form<{ groups: string[] }> { return data; } - renderForm(): TemplateResult { - return html`
- -
- { - this.groupsToAdd = items; - this.requestUpdate(); - return Promise.resolve(); - }} - > - - -
- - ${this.groupsToAdd.map((group) => { - return html` { - const idx = this.groupsToAdd.indexOf(group); - this.groupsToAdd.splice(idx, 1); - this.requestUpdate(); - }} - > - ${group.name} - `; - })} - -
+ renderInlineForm(): TemplateResult { + return html` +
+ { + this.groupsToAdd = items; + this.requestUpdate(); + return Promise.resolve(); + }} + > + + +
+ + ${this.groupsToAdd.map((group) => { + return html` { + const idx = this.groupsToAdd.indexOf(group); + this.groupsToAdd.splice(idx, 1); + this.requestUpdate(); + }} + > + ${group.name} + `; + })} +
- - `; +
+
`; } } diff --git a/web/src/admin/policies/PolicyTestForm.ts b/web/src/admin/policies/PolicyTestForm.ts index 75e47e1e5..0bbeb35d5 100644 --- a/web/src/admin/policies/PolicyTestForm.ts +++ b/web/src/admin/policies/PolicyTestForm.ts @@ -116,9 +116,8 @@ export class PolicyTestForm extends Form { `; } - renderForm(): TemplateResult { - return html`
- + renderInlineForm(): TemplateResult { + return html` => { const args: CoreUsersListRequest = { @@ -155,7 +154,6 @@ export class PolicyTestForm extends Form { ${t`Set custom attributes using YAML or JSON.`}

- ${this.result ? this.renderResult() : html``} - `; + ${this.result ? this.renderResult() : html``}`; } } diff --git a/web/src/admin/property-mappings/PropertyMappingTestForm.ts b/web/src/admin/property-mappings/PropertyMappingTestForm.ts index 76616cd71..f93f04343 100644 --- a/web/src/admin/property-mappings/PropertyMappingTestForm.ts +++ b/web/src/admin/property-mappings/PropertyMappingTestForm.ts @@ -119,9 +119,8 @@ export class PolicyTestForm extends Form { `; } - renderForm(): TemplateResult { - return html`
- + renderInlineForm(): TemplateResult { + return html` => { const args: CoreUsersListRequest = { @@ -156,7 +155,6 @@ export class PolicyTestForm extends Form {

${this.renderExampleButtons()}

- ${this.result ? this.renderResult() : html``} - `; + ${this.result ? this.renderResult() : html``}`; } } diff --git a/web/src/admin/providers/saml/SAMLProviderImportForm.ts b/web/src/admin/providers/saml/SAMLProviderImportForm.ts index 5aa8b4dbd..e30b981ee 100644 --- a/web/src/admin/providers/saml/SAMLProviderImportForm.ts +++ b/web/src/admin/providers/saml/SAMLProviderImportForm.ts @@ -37,9 +37,8 @@ export class SAMLProviderImportForm extends Form { }); } - renderForm(): TemplateResult { - return html`
- + renderInlineForm(): TemplateResult { + return html` { - - `; + `; } } diff --git a/web/src/admin/users/RelatedUserList.ts b/web/src/admin/users/RelatedUserList.ts index 8de713522..5de511bcc 100644 --- a/web/src/admin/users/RelatedUserList.ts +++ b/web/src/admin/users/RelatedUserList.ts @@ -59,9 +59,8 @@ export class RelatedUserAdd extends Form<{ users: number[] }> { return data; } - renderForm(): TemplateResult { - return html`
- ${this.group?.isSuperuser ? html`` : html``} + renderInlineForm(): TemplateResult { + return html`${this.group?.isSuperuser ? html`` : html``}
{
-
- `; +
`; } } diff --git a/web/src/admin/users/ServiceAccountForm.ts b/web/src/admin/users/ServiceAccountForm.ts index 4707af7f3..ac3127921 100644 --- a/web/src/admin/users/ServiceAccountForm.ts +++ b/web/src/admin/users/ServiceAccountForm.ts @@ -35,9 +35,8 @@ export class ServiceAccountForm extends Form { this.result = undefined; } - renderRequestForm(): TemplateResult { - return html`
- + renderInlineForm(): TemplateResult { + return html`

${t`User's primary identifier. 150 characters or fewer.`} @@ -78,8 +77,7 @@ export class ServiceAccountForm extends Form { value="${dateTimeLocal(new Date(Date.now() + 1000 * 60 ** 2 * 24 * 360))}" class="pf-c-form-control" /> - - `; + `; } renderResponseForm(): TemplateResult { @@ -113,6 +111,6 @@ export class ServiceAccountForm extends Form { if (this.result) { return this.renderResponseForm(); } - return this.renderRequestForm(); + return super.renderForm(); } } diff --git a/web/src/admin/users/UserPasswordForm.ts b/web/src/admin/users/UserPasswordForm.ts index b2429a6fd..a93338949 100644 --- a/web/src/admin/users/UserPasswordForm.ts +++ b/web/src/admin/users/UserPasswordForm.ts @@ -26,11 +26,13 @@ export class UserPasswordForm extends Form { }); } - renderForm(): TemplateResult { - return html`

- - - -
`; + renderInlineForm(): TemplateResult { + return html` + + `; } } diff --git a/web/src/admin/users/UserResetEmailForm.ts b/web/src/admin/users/UserResetEmailForm.ts index 123c440c8..fc50de5e4 100644 --- a/web/src/admin/users/UserResetEmailForm.ts +++ b/web/src/admin/users/UserResetEmailForm.ts @@ -32,32 +32,34 @@ export class UserResetEmailForm extends Form - - => { - const args: StagesAllListRequest = { - ordering: "name", - }; - if (query !== undefined) { - args.search = query; - } - const stages = await new StagesApi(DEFAULT_CONFIG).stagesEmailList(args); - return stages.results; - }} - .groupBy=${(items: Stage[]) => { - return groupBy(items, (stage) => stage.verboseNamePlural); - }} - .renderElement=${(stage: Stage): string => { - return stage.name; - }} - .value=${(stage: Stage | undefined): string | undefined => { - return stage?.pk; - }} - > - - - `; + renderInlineForm(): TemplateResult { + return html` + => { + const args: StagesAllListRequest = { + ordering: "name", + }; + if (query !== undefined) { + args.search = query; + } + const stages = await new StagesApi(DEFAULT_CONFIG).stagesEmailList(args); + return stages.results; + }} + .groupBy=${(items: Stage[]) => { + return groupBy(items, (stage) => stage.verboseNamePlural); + }} + .renderElement=${(stage: Stage): string => { + return stage.name; + }} + .value=${(stage: Stage | undefined): string | undefined => { + return stage?.pk; + }} + > + + `; } } diff --git a/web/src/elements/forms/Form.ts b/web/src/elements/forms/Form.ts index 807f7312c..338147c90 100644 --- a/web/src/elements/forms/Form.ts +++ b/web/src/elements/forms/Form.ts @@ -283,9 +283,23 @@ export abstract class Form extends AKElement { } renderForm(): TemplateResult { + const inline = this.renderInlineForm(); + if (inline) { + return html`
+ ${inline} +
`; + } return html``; } + /** + * Inline form render callback when inheriting this class, should be overwritten + * instead of `this.renderForm` + */ + renderInlineForm(): TemplateResult | undefined { + return undefined; + } + renderNonFieldErrors(): TemplateResult { if (!this.nonFieldErrors) { return html``;