diff --git a/authentik/core/api/propertymappings.py b/authentik/core/api/propertymappings.py index b3970f832..cc2542483 100644 --- a/authentik/core/api/propertymappings.py +++ b/authentik/core/api/propertymappings.py @@ -7,7 +7,7 @@ from guardian.shortcuts import get_objects_for_user from rest_framework import mixins from rest_framework.decorators import action from rest_framework.exceptions import PermissionDenied -from rest_framework.fields import CharField +from rest_framework.fields import BooleanField, CharField from rest_framework.request import Request from rest_framework.response import Response from rest_framework.serializers import ModelSerializer, SerializerMethodField @@ -29,6 +29,7 @@ class PropertyMappingTestResultSerializer(PassiveSerializer): """Result of a Property-mapping test""" result = CharField(read_only=True) + successful = BooleanField(read_only=True) class PropertyMappingSerializer(ModelSerializer, MetaNameSerializer): @@ -115,7 +116,9 @@ class PropertyMappingViewSet( if not users.exists(): raise PermissionDenied() - response_data = {} + response_data = { + "successful": True + } try: result = mapping.evaluate( users.first(), @@ -125,5 +128,6 @@ class PropertyMappingViewSet( response_data["result"] = dumps(result) except Exception as exc: # pylint: disable=broad-except response_data["result"] = str(exc) + response_data["successful"] = False response = PropertyMappingTestResultSerializer(response_data) return Response(response.data) diff --git a/swagger.yaml b/swagger.yaml index b7a05f9e3..c0f1a20c5 100755 --- a/swagger.yaml +++ b/swagger.yaml @@ -16888,6 +16888,10 @@ definitions: type: string readOnly: true minLength: 1 + successful: + title: Successful + type: boolean + readOnly: true LDAPPropertyMapping: required: - name diff --git a/web/src/elements/forms/ModalForm.ts b/web/src/elements/forms/ModalForm.ts index b3d21bb5e..2590c3485 100644 --- a/web/src/elements/forms/ModalForm.ts +++ b/web/src/elements/forms/ModalForm.ts @@ -1,5 +1,5 @@ import { gettext } from "django"; -import { customElement, html, TemplateResult } from "lit-element"; +import { customElement, html, property, TemplateResult } from "lit-element"; import { EVENT_REFRESH } from "../../constants"; import { ModalButton } from "../buttons/ModalButton"; import { Form } from "./Form"; @@ -7,6 +7,9 @@ import { Form } from "./Form"; @customElement("ak-forms-modal") export class ModalForm extends ModalButton { + @property({ type: Boolean }) + closeAfterSuccessfulSubmit = true; + confirm(): void { this.querySelectorAll