web/admin: fix ak-application-check-access-form for get api

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-06-13 22:40:51 +02:00
parent d824b09365
commit 09cd8f8f63
1 changed files with 7 additions and 7 deletions

View File

@ -1,4 +1,4 @@
import { Application, CoreApi, CheckAccessRequestRequest, PolicyTestResult } from "authentik-api"; import { Application, CoreApi, PolicyTestResult } from "authentik-api";
import { t } from "@lingui/macro"; import { t } from "@lingui/macro";
import { customElement, property } from "lit-element"; import { customElement, property } from "lit-element";
import { html, TemplateResult } from "lit-html"; import { html, TemplateResult } from "lit-html";
@ -8,7 +8,7 @@ import { until } from "lit-html/directives/until";
import "../../elements/forms/HorizontalFormElement"; import "../../elements/forms/HorizontalFormElement";
@customElement("ak-application-check-access-form") @customElement("ak-application-check-access-form")
export class ApplicationCheckAccessForm extends Form<CheckAccessRequestRequest> { export class ApplicationCheckAccessForm extends Form<number> {
@property({attribute: false}) @property({attribute: false})
application!: Application; application!: Application;
@ -17,17 +17,17 @@ export class ApplicationCheckAccessForm extends Form<CheckAccessRequestRequest>
result?: PolicyTestResult; result?: PolicyTestResult;
@property({ attribute: false}) @property({ attribute: false})
request?: CheckAccessRequestRequest; request?: number;
getSuccessMessage(): string { getSuccessMessage(): string {
return t`Successfully sent test-request.`; return t`Successfully sent test-request.`;
} }
send = (data: CheckAccessRequestRequest): Promise<PolicyTestResult> => { send = (data: number): Promise<PolicyTestResult> => {
this.request = data; this.request = data;
return new CoreApi(DEFAULT_CONFIG).coreApplicationsCheckAccessCreate({ return new CoreApi(DEFAULT_CONFIG).coreApplicationsCheckAccessRetrieve({
slug: this.application?.slug, slug: this.application?.slug,
checkAccessRequestRequest: data, forUser: data,
}).then(result => this.result = result); }).then(result => this.result = result);
}; };
@ -68,7 +68,7 @@ export class ApplicationCheckAccessForm extends Form<CheckAccessRequestRequest>
ordering: "username", ordering: "username",
}).then(users => { }).then(users => {
return users.results.map(user => { return users.results.map(user => {
return html`<option ?selected=${user.pk.toString() === this.request?.forUser?.toString()} value=${user.pk}>${user.username}</option>`; return html`<option ?selected=${user.pk.toString() === this.request?.toString()} value=${user.pk}>${user.username}</option>`;
}); });
}), html`<option>${t`Loading...`}</option>`)} }), html`<option>${t`Loading...`}</option>`)}
</select> </select>