web/admin: add notice for recovery

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-09-24 11:50:52 +02:00
parent cab7593dca
commit e681654af7
1 changed files with 68 additions and 62 deletions

View File

@ -171,72 +171,78 @@ export class UserListPage extends TablePage<User> {
</div> </div>
</dd> </dd>
</div> </div>
${until( <div class="pf-c-description-list__group">
tenant().then((te) => { <dt class="pf-c-description-list__term">
if (!te.flowRecovery) { <span class="pf-c-description-list__text">${t`Recovery`}</span>
return html``; </dt>
} <dd class="pf-c-description-list__description">
return html`<div class="pf-c-description-list__group"> <div class="pf-c-description-list__text">
<dt class="pf-c-description-list__term"> ${until(
<span class="pf-c-description-list__text" tenant().then((te) => {
>${t`Recovery`}</span if (!te.flowRecovery) {
> return html`
</dt> <p>
<dd class="pf-c-description-list__description"> ${t`To directly reset a user's password, configure a recovery flow on the currently active tenant.`}
<div class="pf-c-description-list__text"> </p>
<ak-action-button `;
.apiRequest=${() => { }
return new CoreApi(DEFAULT_CONFIG) return html`
.coreUsersRecoveryRetrieve({ <ak-action-button
id: item.pk || 0, .apiRequest=${() => {
}) return new CoreApi(DEFAULT_CONFIG)
.then((rec) => { .coreUsersRecoveryRetrieve({
showMessage({ id: item.pk || 0,
level: MessageLevel.success, })
message: t`Successfully generated recovery link`, .then((rec) => {
description: rec.link,
});
})
.catch((ex: Response) => {
ex.json().then(() => {
showMessage({ showMessage({
level: MessageLevel.error, level: MessageLevel.success,
message: t`No recovery flow is configured.`, 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`Copy recovery link`}
${t`Copy recovery link`} </ak-action-button>
</ak-action-button> ${item.email
${item.email ? html`<ak-forms-modal
? html`<ak-forms-modal .closeAfterSuccessfulSubmit=${false}
.closeAfterSuccessfulSubmit=${false}
>
<span slot="submit"> ${t`Send link`} </span>
<span slot="header">
${t`Send recovery link to user`}
</span>
<ak-user-reset-email-form
slot="form"
.user=${item}
> >
</ak-user-reset-email-form> <span slot="submit">
<button ${t`Send link`}
slot="trigger" </span>
class="pf-c-button pf-m-secondary" <span slot="header">
> ${t`Send recovery link to user`}
${t`Email recovery link`} </span>
</button> <ak-user-reset-email-form
</ak-forms-modal>` slot="form"
: html`<span .user=${item}
>${t`Recovery link cannot be emailed, user has no email address saved.`}</span >
>`} </ak-user-reset-email-form>
</div> <button
</dd> slot="trigger"
</div>`; class="pf-c-button pf-m-secondary"
}), >
)} ${t`Email recovery link`}
</button>
</ak-forms-modal>`
: html`<span
>${t`Recovery link cannot be emailed, user has no email address saved.`}</span
>`}
`;
}),
)}
</div>
</dd>
</div>
</dl> </dl>
</div> </div>
</td> </td>