From 14f341f50461d8c00ce01a277ae2151f0012b6b3 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 21 Nov 2022 21:36:10 +0100 Subject: [PATCH] web/admin: fix error when importing duo devices Signed-off-by: Jens Langhammer --- authentik/stages/authenticator_duo/api.py | 4 ++-- .../stages/authenticator_duo/DuoDeviceImportForm.ts | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/authentik/stages/authenticator_duo/api.py b/authentik/stages/authenticator_duo/api.py index 4f93dee39..423679773 100644 --- a/authentik/stages/authenticator_duo/api.py +++ b/authentik/stages/authenticator_duo/api.py @@ -118,12 +118,12 @@ class AuthenticatorDuoStageViewSet(UsedByMixin, ModelViewSet): .first() ) if not user: - return Response(data={"non_field_errors": ["user does not exist"]}, status=400) + return Response(data={"non_field_errors": ["User does not exist."]}, status=400) device = DuoDevice.objects.filter( duo_user_id=request.data.get("duo_user_id"), user=user, stage=stage ).first() if device: - return Response(data={"non_field_errors": ["device exists already"]}, status=400) + return Response(data={"non_field_errors": ["Device exists already."]}, status=400) DuoDevice.objects.create( duo_user_id=request.data.get("duo_user_id"), user=user, diff --git a/web/src/admin/stages/authenticator_duo/DuoDeviceImportForm.ts b/web/src/admin/stages/authenticator_duo/DuoDeviceImportForm.ts index 8f24116e4..1e44865d6 100644 --- a/web/src/admin/stages/authenticator_duo/DuoDeviceImportForm.ts +++ b/web/src/admin/stages/authenticator_duo/DuoDeviceImportForm.ts @@ -16,9 +16,9 @@ import { until } from "lit/directives/until.js"; import { AuthenticatorDuoStage, + AuthenticatorDuoStageManualDeviceImportRequest, CoreApi, StagesApi, - StagesAuthenticatorDuoImportDeviceManualCreateRequest, } from "@goauthentik/api"; @customElement("ak-stage-authenticator-duo-device-import-form") @@ -34,11 +34,11 @@ export class DuoDeviceImportForm extends ModelForm => { - const importData = data as unknown as StagesAuthenticatorDuoImportDeviceManualCreateRequest; - importData.stageUuid = this.instancePk; - return new StagesApi(DEFAULT_CONFIG).stagesAuthenticatorDuoImportDeviceManualCreate( - importData, - ); + const importData = data as unknown as AuthenticatorDuoStageManualDeviceImportRequest; + return new StagesApi(DEFAULT_CONFIG).stagesAuthenticatorDuoImportDeviceManualCreate({ + stageUuid: this.instance?.pk || "", + authenticatorDuoStageManualDeviceImportRequest: importData, + }); }; renderForm(): TemplateResult {