core: only show Reset password link when recovery flow is configured

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2021-07-04 12:44:57 +02:00
parent ca44f8bd60
commit 320dab3425
3 changed files with 37 additions and 27 deletions

View File

@ -9,13 +9,14 @@ import "../../elements/buttons/ActionButton";
import { TableColumn } from "../../elements/table/Table";
import { PAGE_SIZE } from "../../constants";
import { CoreApi, User } from "authentik-api";
import { DEFAULT_CONFIG } from "../../api/Config";
import { DEFAULT_CONFIG, tenant } from "../../api/Config";
import "../../elements/forms/DeleteForm";
import "./UserActiveForm";
import "./UserForm";
import { showMessage } from "../../elements/messages/MessageContainer";
import { MessageLevel } from "../../elements/messages/Message";
import { first } from "../../utils";
import { until } from "lit-html/directives/until";
@customElement("ak-user-list")
export class UserListPage extends TablePage<User> {
@ -128,27 +129,33 @@ export class UserListPage extends TablePage<User> {
</li>
</ul>
</ak-dropdown>
<ak-action-button
.apiRequest=${() => {
return new CoreApi(DEFAULT_CONFIG).coreUsersRecoveryRetrieve({
id: item.pk || 0,
}).then(rec => {
showMessage({
level: MessageLevel.success,
message: t`Successfully generated recovery link`,
description: rec.link
});
}).catch((ex: Response) => {
ex.json().then(() => {
showMessage({
level: MessageLevel.error,
message: t`No recovery flow is configured.`,
});
});
});
}}>
${t`Reset Password`}
</ak-action-button>
${until(tenant().then(te => {
if (te.flowRecovery) {
return html`
<ak-action-button
.apiRequest=${() => {
return new CoreApi(DEFAULT_CONFIG).coreUsersRecoveryRetrieve({
id: item.pk || 0,
}).then(rec => {
showMessage({
level: MessageLevel.success,
message: t`Successfully generated recovery link`,
description: rec.link
});
}).catch((ex: Response) => {
ex.json().then(() => {
showMessage({
level: MessageLevel.error,
message: t`No recovery flow is configured.`,
});
});
});
}}>
${t`Reset Password`}
</ak-action-button>`;
}
return html``;
}))}
<a class="pf-c-button pf-m-tertiary" href="${`/-/impersonation/${item.pk}/`}">
${t`Impersonate`}
</a>`,