Debian Codegraph @

pkg/users/lock-account-dialog.js

raw
1 /*
2 * Copyright (C) 2020 Red Hat, Inc.
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6 import cockpit from 'cockpit';
7
8 import { show_modal_dialog } from "cockpit-components-dialog.jsx";
9
10 const _ = cockpit.gettext;
11
12 export const lockAccountDialog = (account) => {
13 const props = {
14 id: "account-confirm-lock-dialog",
15 title: cockpit.format(_("Lock $0"), account.name),
16 };
17
18 const footer = {
19 actions: [
20 {
21 style: "danger",
22 caption: _("Lock"),
23 clicked: () => {
24 return cockpit.spawn(["/usr/sbin/usermod", account.name, "--lock"], { superuser: "require", err: "message" })
25 .catch(err => console.warn("Failed to log user out", err));
26 },
27 }
28 ]
29 };
30
31 show_modal_dialog(props, footer);
32 };