web/*: fix defaults for booleans to use first()

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-04-04 00:36:53 +02:00
parent 46e0571ed0
commit 8a7c414031
23 changed files with 54 additions and 39 deletions

View File

@ -10,7 +10,7 @@ import { MessageMiddleware } from "../elements/messages/Middleware";
export class LoggingMiddleware implements Middleware { export class LoggingMiddleware implements Middleware {
post(context: ResponseContext): Promise<Response | void> { post(context: ResponseContext): Promise<Response | void> {
console.debug(`authentik/api: ${context.init.method} ${context.url} => ${context.response.status}`); console.debug(`authentik/api: ${context.response.status} ${context.init.method} ${context.url}`);
return Promise.resolve(context.response); return Promise.resolve(context.response);
} }
} }

View File

@ -6,6 +6,7 @@ import { DEFAULT_CONFIG } from "../../api/Config";
import { Form } from "../../elements/forms/Form"; import { Form } from "../../elements/forms/Form";
import { ifDefined } from "lit-html/directives/if-defined"; import { ifDefined } from "lit-html/directives/if-defined";
import "../../elements/forms/HorizontalFormElement"; import "../../elements/forms/HorizontalFormElement";
import { first } from "../../utils";
@customElement("ak-event-transport-form") @customElement("ak-event-transport-form")
export class TransportForm extends Form<NotificationTransport> { export class TransportForm extends Form<NotificationTransport> {
@ -92,7 +93,7 @@ export class TransportForm extends Form<NotificationTransport> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="sendOnce"> <ak-form-element-horizontal name="sendOnce">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.transport?.sendOnce || false}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.transport?.sendOnce, false)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Send once`} ${t`Send once`}
</label> </label>

View File

@ -7,7 +7,7 @@ import { Form } from "../../elements/forms/Form";
import { until } from "lit-html/directives/until"; import { until } from "lit-html/directives/until";
import { ifDefined } from "lit-html/directives/if-defined"; import { ifDefined } from "lit-html/directives/if-defined";
import "../../elements/forms/HorizontalFormElement"; import "../../elements/forms/HorizontalFormElement";
import { groupBy } from "../../utils"; import { first, groupBy } from "../../utils";
@customElement("ak-stage-binding-form") @customElement("ak-stage-binding-form")
export class StageBindingForm extends Form<FlowStageBinding> { export class StageBindingForm extends Form<FlowStageBinding> {
@ -104,7 +104,7 @@ export class StageBindingForm extends Form<FlowStageBinding> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="evaluateOnPlan"> <ak-form-element-horizontal name="evaluateOnPlan">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.fsb?.evaluateOnPlan || true}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.fsb?.evaluateOnPlan, true)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Evaluate on plan`} ${t`Evaluate on plan`}
</label> </label>
@ -113,7 +113,7 @@ export class StageBindingForm extends Form<FlowStageBinding> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="reEvaluatePolicies"> <ak-form-element-horizontal name="reEvaluatePolicies">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.fsb?.reEvaluatePolicies || false}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.fsb?.reEvaluatePolicies, false)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Re-evaluate policies`} ${t`Re-evaluate policies`}
</label> </label>

View File

@ -9,6 +9,7 @@ import { ifDefined } from "lit-html/directives/if-defined";
import "../../elements/forms/HorizontalFormElement"; import "../../elements/forms/HorizontalFormElement";
import "../../elements/CodeMirror"; import "../../elements/CodeMirror";
import YAML from "yaml"; import YAML from "yaml";
import { first } from "../../utils";
@customElement("ak-group-form") @customElement("ak-group-form")
export class GroupForm extends Form<Group> { export class GroupForm extends Form<Group> {
@ -47,7 +48,7 @@ export class GroupForm extends Form<Group> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="isSuperuser"> <ak-form-element-horizontal name="isSuperuser">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.group?.isSuperuser || false}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.group?.isSuperuser, false)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Is superuser`} ${t`Is superuser`}
</label> </label>

View File

@ -7,6 +7,7 @@ import { Form } from "../../elements/forms/Form";
import { until } from "lit-html/directives/until"; import { until } from "lit-html/directives/until";
import { ifDefined } from "lit-html/directives/if-defined"; import { ifDefined } from "lit-html/directives/if-defined";
import "../../elements/forms/HorizontalFormElement"; import "../../elements/forms/HorizontalFormElement";
import { first } from "../../utils";
@customElement("ak-service-connection-docker-form") @customElement("ak-service-connection-docker-form")
export class ServiceConnectionDockerForm extends Form<DockerServiceConnection> { export class ServiceConnectionDockerForm extends Form<DockerServiceConnection> {
@ -53,7 +54,7 @@ export class ServiceConnectionDockerForm extends Form<DockerServiceConnection> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="local"> <ak-form-element-horizontal name="local">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.sc?.local || false}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.sc?.local, false)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Local`} ${t`Local`}
</label> </label>

View File

@ -8,6 +8,7 @@ import { ifDefined } from "lit-html/directives/if-defined";
import "../../elements/forms/HorizontalFormElement"; import "../../elements/forms/HorizontalFormElement";
import "../../elements/CodeMirror"; import "../../elements/CodeMirror";
import YAML from "yaml"; import YAML from "yaml";
import { first } from "../../utils";
@customElement("ak-service-connection-kubernetes-form") @customElement("ak-service-connection-kubernetes-form")
export class ServiceConnectionKubernetesForm extends Form<KubernetesServiceConnection> { export class ServiceConnectionKubernetesForm extends Form<KubernetesServiceConnection> {
@ -54,7 +55,7 @@ export class ServiceConnectionKubernetesForm extends Form<KubernetesServiceConne
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="local"> <ak-form-element-horizontal name="local">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.sc?.local || false}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.sc?.local, false)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Local`} ${t`Local`}
</label> </label>

View File

@ -114,7 +114,7 @@ export class PolicyBindingForm extends Form<PolicyBinding> {
<input required name="target" type="hidden" value=${ifDefined(this.binding?.target || this.targetPk)}> <input required name="target" type="hidden" value=${ifDefined(this.binding?.target || this.targetPk)}>
<ak-form-element-horizontal name="enabled"> <ak-form-element-horizontal name="enabled">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.binding?.enabled || true}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.binding?.enabled, true)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Enabled`} ${t`Enabled`}
</label> </label>

View File

@ -54,7 +54,7 @@ export class DummyPolicyForm extends Form<DummyPolicy> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="executionLogging"> <ak-form-element-horizontal name="executionLogging">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.policy?.executionLogging || false}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.policy?.executionLogging, false)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Execution logging`} ${t`Execution logging`}
</label> </label>
@ -68,7 +68,7 @@ export class DummyPolicyForm extends Form<DummyPolicy> {
<div slot="body" class="pf-c-form"> <div slot="body" class="pf-c-form">
<ak-form-element-horizontal name="result"> <ak-form-element-horizontal name="result">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.policy?.result || false}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.policy?.result, false)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Pass policy?`} ${t`Pass policy?`}
</label> </label>

View File

@ -8,6 +8,7 @@ import { ifDefined } from "lit-html/directives/if-defined";
import "../../../elements/forms/HorizontalFormElement"; import "../../../elements/forms/HorizontalFormElement";
import "../../../elements/forms/FormGroup"; import "../../../elements/forms/FormGroup";
import { until } from "lit-html/directives/until"; import { until } from "lit-html/directives/until";
import { first } from "../../../utils";
@customElement("ak-policy-event-matcher-form") @customElement("ak-policy-event-matcher-form")
export class EventMatcherPolicyForm extends Form<EventMatcherPolicy> { export class EventMatcherPolicyForm extends Form<EventMatcherPolicy> {
@ -54,7 +55,7 @@ export class EventMatcherPolicyForm extends Form<EventMatcherPolicy> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="executionLogging"> <ak-form-element-horizontal name="executionLogging">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.policy?.executionLogging || false}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.policy?.executionLogging, false)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Execution logging`} ${t`Execution logging`}
</label> </label>

View File

@ -7,6 +7,7 @@ import { Form } from "../../../elements/forms/Form";
import { ifDefined } from "lit-html/directives/if-defined"; import { ifDefined } from "lit-html/directives/if-defined";
import "../../../elements/forms/HorizontalFormElement"; import "../../../elements/forms/HorizontalFormElement";
import "../../../elements/forms/FormGroup"; import "../../../elements/forms/FormGroup";
import { first } from "../../../utils";
@customElement("ak-policy-password-expiry-form") @customElement("ak-policy-password-expiry-form")
export class PasswordExpiryPolicyForm extends Form<PasswordExpiryPolicy> { export class PasswordExpiryPolicyForm extends Form<PasswordExpiryPolicy> {
@ -53,7 +54,7 @@ export class PasswordExpiryPolicyForm extends Form<PasswordExpiryPolicy> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="executionLogging"> <ak-form-element-horizontal name="executionLogging">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.policy?.executionLogging || false}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.policy?.executionLogging, false)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Execution logging`} ${t`Execution logging`}
</label> </label>
@ -73,7 +74,7 @@ export class PasswordExpiryPolicyForm extends Form<PasswordExpiryPolicy> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="denyOnly"> <ak-form-element-horizontal name="denyOnly">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.policy?.denyOnly || false}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.policy?.denyOnly, false)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Only fail the policy, don't set user's password.`} ${t`Only fail the policy, don't set user's password.`}
</label> </label>

View File

@ -8,6 +8,7 @@ import { ifDefined } from "lit-html/directives/if-defined";
import "../../../elements/forms/HorizontalFormElement"; import "../../../elements/forms/HorizontalFormElement";
import "../../../elements/forms/FormGroup"; import "../../../elements/forms/FormGroup";
import "../../../elements/CodeMirror"; import "../../../elements/CodeMirror";
import { first } from "../../../utils";
@customElement("ak-policy-expression-form") @customElement("ak-policy-expression-form")
export class ExpressionPolicyForm extends Form<ExpressionPolicy> { export class ExpressionPolicyForm extends Form<ExpressionPolicy> {
@ -54,7 +55,7 @@ export class ExpressionPolicyForm extends Form<ExpressionPolicy> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="executionLogging"> <ak-form-element-horizontal name="executionLogging">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.policy?.executionLogging || false}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.policy?.executionLogging, false)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Execution logging`} ${t`Execution logging`}
</label> </label>

View File

@ -54,7 +54,7 @@ export class HaveIBeenPwnedPolicyForm extends Form<HaveIBeenPwendPolicy> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="executionLogging"> <ak-form-element-horizontal name="executionLogging">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.policy?.executionLogging || false}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.policy?.executionLogging, false)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Execution logging`} ${t`Execution logging`}
</label> </label>

View File

@ -54,7 +54,7 @@ export class PasswordPolicyForm extends Form<PasswordPolicy> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="executionLogging"> <ak-form-element-horizontal name="executionLogging">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.policy?.executionLogging || false}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.policy?.executionLogging, false)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Execution logging`} ${t`Execution logging`}
</label> </label>

View File

@ -7,6 +7,7 @@ import { Form } from "../../../elements/forms/Form";
import { ifDefined } from "lit-html/directives/if-defined"; import { ifDefined } from "lit-html/directives/if-defined";
import "../../../elements/forms/HorizontalFormElement"; import "../../../elements/forms/HorizontalFormElement";
import "../../../elements/forms/FormGroup"; import "../../../elements/forms/FormGroup";
import { first } from "../../../utils";
@customElement("ak-policy-reputation-form") @customElement("ak-policy-reputation-form")
export class ReputationPolicyForm extends Form<ReputationPolicy> { export class ReputationPolicyForm extends Form<ReputationPolicy> {
@ -53,7 +54,7 @@ export class ReputationPolicyForm extends Form<ReputationPolicy> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="executionLogging"> <ak-form-element-horizontal name="executionLogging">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.policy?.executionLogging || false}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.policy?.executionLogging, false)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Execution logging`} ${t`Execution logging`}
</label> </label>
@ -67,7 +68,7 @@ export class ReputationPolicyForm extends Form<ReputationPolicy> {
<div slot="body" class="pf-c-form"> <div slot="body" class="pf-c-form">
<ak-form-element-horizontal name="checkIp"> <ak-form-element-horizontal name="checkIp">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.policy?.checkIp || false}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.policy?.checkIp, false)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Check IP`} ${t`Check IP`}
</label> </label>
@ -75,7 +76,7 @@ export class ReputationPolicyForm extends Form<ReputationPolicy> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="checkUsername"> <ak-form-element-horizontal name="checkUsername">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.policy?.checkUsername || false}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.policy?.checkUsername, false)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Check Username`} ${t`Check Username`}
</label> </label>

View File

@ -205,7 +205,7 @@ export class OAuth2ProviderFormPage extends Form<OAuth2Provider> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="includeClaimsInIdToken"> <ak-form-element-horizontal name="includeClaimsInIdToken">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.provider?.includeClaimsInIdToken || false}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.provider?.includeClaimsInIdToken, true)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Include claims in id_token`} ${t`Include claims in id_token`}
</label> </label>

View File

@ -8,6 +8,7 @@ import "../../../elements/forms/FormGroup";
import "../../../elements/forms/HorizontalFormElement"; import "../../../elements/forms/HorizontalFormElement";
import { ifDefined } from "lit-html/directives/if-defined"; import { ifDefined } from "lit-html/directives/if-defined";
import { until } from "lit-html/directives/until"; import { until } from "lit-html/directives/until";
import { first } from "../../../utils";
@customElement("ak-source-ldap-form") @customElement("ak-source-ldap-form")
export class LDAPSourceForm extends Form<LDAPSource> { export class LDAPSourceForm extends Form<LDAPSource> {
@ -60,7 +61,7 @@ export class LDAPSourceForm extends Form<LDAPSource> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="enabled"> <ak-form-element-horizontal name="enabled">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.source?.enabled || true}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.source?.enabled, true)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Enabled`} ${t`Enabled`}
</label> </label>
@ -68,7 +69,7 @@ export class LDAPSourceForm extends Form<LDAPSource> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="syncUsers"> <ak-form-element-horizontal name="syncUsers">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.source?.syncUsers || true}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.source?.syncUsers, true)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Sync users`} ${t`Sync users`}
</label> </label>
@ -76,7 +77,7 @@ export class LDAPSourceForm extends Form<LDAPSource> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="syncUsersPassword"> <ak-form-element-horizontal name="syncUsersPassword">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.source?.syncUsersPassword || true}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.source?.syncUsersPassword, true)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Sync users' passwords`} ${t`Sync users' passwords`}
</label> </label>
@ -84,7 +85,7 @@ export class LDAPSourceForm extends Form<LDAPSource> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="syncGroups"> <ak-form-element-horizontal name="syncGroups">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.source?.syncGroups || true}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.source?.syncGroups, true)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Sync groups`} ${t`Sync groups`}
</label> </label>
@ -103,7 +104,7 @@ export class LDAPSourceForm extends Form<LDAPSource> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="startTls"> <ak-form-element-horizontal name="startTls">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.source?.startTls || true}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.source?.startTls, true)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Enable StartTLS`} ${t`Enable StartTLS`}
</label> </label>
@ -140,7 +141,7 @@ export class LDAPSourceForm extends Form<LDAPSource> {
name="propertyMappings"> name="propertyMappings">
<select class="pf-c-form-control" multiple> <select class="pf-c-form-control" multiple>
${until(new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsLdapList({ ${until(new PropertymappingsApi(DEFAULT_CONFIG).propertymappingsLdapList({
ordering: "object_field" ordering: "managed,object_field"
}).then(mappings => { }).then(mappings => {
return mappings.results.map(mapping => { return mappings.results.map(mapping => {
let selected = false; let selected = false;

View File

@ -8,6 +8,7 @@ import "../../../elements/forms/FormGroup";
import "../../../elements/forms/HorizontalFormElement"; import "../../../elements/forms/HorizontalFormElement";
import { ifDefined } from "lit-html/directives/if-defined"; import { ifDefined } from "lit-html/directives/if-defined";
import { until } from "lit-html/directives/until"; import { until } from "lit-html/directives/until";
import { first } from "../../../utils";
@customElement("ak-source-oauth-form") @customElement("ak-source-oauth-form")
export class OAuthSourceForm extends Form<OAuthSource> { export class OAuthSourceForm extends Form<OAuthSource> {
@ -17,7 +18,7 @@ export class OAuthSourceForm extends Form<OAuthSource> {
slug: value, slug: value,
}).then(source => { }).then(source => {
this.source = source; this.source = source;
this.showUrlOptions = source.type?.urlsCustomizable || false; this.showUrlOptions = first(source.type?.urlsCustomizable, false);
}); });
} }
@ -105,7 +106,7 @@ export class OAuthSourceForm extends Form<OAuthSource> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="enabled"> <ak-form-element-horizontal name="enabled">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.source?.enabled || true}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.source?.enabled, true)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Enabled`} ${t`Enabled`}
</label> </label>

View File

@ -8,6 +8,7 @@ import "../../../elements/forms/FormGroup";
import "../../../elements/forms/HorizontalFormElement"; import "../../../elements/forms/HorizontalFormElement";
import { ifDefined } from "lit-html/directives/if-defined"; import { ifDefined } from "lit-html/directives/if-defined";
import { until } from "lit-html/directives/until"; import { until } from "lit-html/directives/until";
import { first } from "../../../utils";
@customElement("ak-source-saml-form") @customElement("ak-source-saml-form")
export class SAMLSourceForm extends Form<SAMLSource> { export class SAMLSourceForm extends Form<SAMLSource> {
@ -60,7 +61,7 @@ export class SAMLSourceForm extends Form<SAMLSource> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="enabled"> <ak-form-element-horizontal name="enabled">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.source?.enabled || true}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.source?.enabled, true)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Enabled`} ${t`Enabled`}
</label> </label>
@ -131,7 +132,7 @@ export class SAMLSourceForm extends Form<SAMLSource> {
<div slot="body" class="pf-c-form"> <div slot="body" class="pf-c-form">
<ak-form-element-horizontal name="allowIdpInitiated"> <ak-form-element-horizontal name="allowIdpInitiated">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.source?.allowIdpInitiated || false}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.source?.allowIdpInitiated, false)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t` Allow IDP-initiated logins`} ${t` Allow IDP-initiated logins`}
</label> </label>

View File

@ -82,7 +82,7 @@ export class EmailStageForm extends Form<EmailStage> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="useTls"> <ak-form-element-horizontal name="useTls">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.stage?.useTls || true}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.stage?.useTls, true)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Use TLS`} ${t`Use TLS`}
</label> </label>
@ -90,7 +90,7 @@ export class EmailStageForm extends Form<EmailStage> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="useSsl"> <ak-form-element-horizontal name="useSsl">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.stage?.useSsl || true}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.stage?.useSsl, true)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Use SSL`} ${t`Use SSL`}
</label> </label>
@ -127,7 +127,7 @@ export class EmailStageForm extends Form<EmailStage> {
<div slot="body" class="pf-c-form"> <div slot="body" class="pf-c-form">
<ak-form-element-horizontal name="useGlobalSettings"> <ak-form-element-horizontal name="useGlobalSettings">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.stage?.useGlobalSettings || true} @change=${(ev: Event) => { <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.stage?.useGlobalSettings, true)} @change=${(ev: Event) => {
const target = ev.target as HTMLInputElement; const target = ev.target as HTMLInputElement;
this.showConnectionSettings = !target.checked; this.showConnectionSettings = !target.checked;
}}> }}>

View File

@ -8,6 +8,7 @@ import { ifDefined } from "lit-html/directives/if-defined";
import "../../../elements/forms/HorizontalFormElement"; import "../../../elements/forms/HorizontalFormElement";
import "../../../elements/forms/FormGroup"; import "../../../elements/forms/FormGroup";
import { until } from "lit-html/directives/until"; import { until } from "lit-html/directives/until";
import { first } from "../../../utils";
@customElement("ak-stage-identification-form") @customElement("ak-stage-identification-form")
export class IdentificationStageForm extends Form<IdentificationStage> { export class IdentificationStageForm extends Form<IdentificationStage> {
@ -80,7 +81,7 @@ export class IdentificationStageForm extends Form<IdentificationStage> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="caseInsensitiveMatching"> <ak-form-element-horizontal name="caseInsensitiveMatching">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.stage?.caseInsensitiveMatching || true}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.stage?.caseInsensitiveMatching, true)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Case insensitive matching`} ${t`Case insensitive matching`}
</label> </label>
@ -89,7 +90,7 @@ export class IdentificationStageForm extends Form<IdentificationStage> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="showMatchedUser"> <ak-form-element-horizontal name="showMatchedUser">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.stage?.showMatchedUser || true}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.stage?.showMatchedUser, true)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Show matched user`} ${t`Show matched user`}
</label> </label>

View File

@ -7,6 +7,7 @@ import { Form } from "../../../elements/forms/Form";
import { ifDefined } from "lit-html/directives/if-defined"; import { ifDefined } from "lit-html/directives/if-defined";
import "../../../elements/forms/HorizontalFormElement"; import "../../../elements/forms/HorizontalFormElement";
import "../../../elements/forms/FormGroup"; import "../../../elements/forms/FormGroup";
import { first } from "../../../utils";
@customElement("ak-stage-invitation-form") @customElement("ak-stage-invitation-form")
export class InvitationStageForm extends Form<InvitationStage> { export class InvitationStageForm extends Form<InvitationStage> {
@ -58,7 +59,7 @@ export class InvitationStageForm extends Form<InvitationStage> {
<div slot="body" class="pf-c-form"> <div slot="body" class="pf-c-form">
<ak-form-element-horizontal name="continueFlowWithoutInvitation"> <ak-form-element-horizontal name="continueFlowWithoutInvitation">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.stage?.continueFlowWithoutInvitation || true}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.stage?.continueFlowWithoutInvitation, true)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Continue flow without invitation`} ${t`Continue flow without invitation`}
</label> </label>

View File

@ -6,6 +6,7 @@ import { DEFAULT_CONFIG } from "../../../api/Config";
import { Form } from "../../../elements/forms/Form"; import { Form } from "../../../elements/forms/Form";
import { ifDefined } from "lit-html/directives/if-defined"; import { ifDefined } from "lit-html/directives/if-defined";
import "../../../elements/forms/HorizontalFormElement"; import "../../../elements/forms/HorizontalFormElement";
import { first } from "../../../utils";
@customElement("ak-prompt-form") @customElement("ak-prompt-form")
export class PromptForm extends Form<Prompt> { export class PromptForm extends Form<Prompt> {
@ -98,7 +99,7 @@ export class PromptForm extends Form<Prompt> {
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal name="required"> <ak-form-element-horizontal name="required">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.prompt?.required || false}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.prompt?.required, false)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Required`} ${t`Required`}
</label> </label>

View File

@ -8,6 +8,7 @@ import { ifDefined } from "lit-html/directives/if-defined";
import "../../elements/forms/HorizontalFormElement"; import "../../elements/forms/HorizontalFormElement";
import "../../elements/CodeMirror"; import "../../elements/CodeMirror";
import YAML from "yaml"; import YAML from "yaml";
import { first } from "../../utils";
@customElement("ak-user-form") @customElement("ak-user-form")
export class UserForm extends Form<User> { export class UserForm extends Form<User> {
@ -61,7 +62,7 @@ export class UserForm extends Form<User> {
<ak-form-element-horizontal <ak-form-element-horizontal
name="isActive"> name="isActive">
<div class="pf-c-check"> <div class="pf-c-check">
<input type="checkbox" class="pf-c-check__input" ?checked=${this.user?.isActive || false}> <input type="checkbox" class="pf-c-check__input" ?checked=${first(this.user?.isActive, false)}>
<label class="pf-c-check__label"> <label class="pf-c-check__label">
${t`Is active`} ${t`Is active`}
</label> </label>