web/admin: fix error when importing duo devices
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
c30aa90888
commit
14f341f504
|
@ -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,
|
||||
|
|
|
@ -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<AuthenticatorDuoStage, string
|
|||
}
|
||||
|
||||
send = (data: AuthenticatorDuoStage): Promise<void> => {
|
||||
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 {
|
||||
|
|
Reference in New Issue