]>
git.proxmox.com Git - pve-manager.git/blob - www/manager6/dc/UserView.js
fec45deb704903d671985e51d883ac188221078d
1 Ext
.define('PVE.dc.UserView', {
2 extend
: 'Ext.grid.GridPanel',
4 alias
: ['widget.pveUserView'],
6 onlineHelp
: 'pveum_users',
11 initComponent: function() {
14 var caps
= Ext
.state
.Manager
.get('GuiCap');
16 var store
= new Ext
.data
.Store({
24 let reload
= () => store
.load();
26 let sm
= Ext
.create('Ext.selection.RowModel', {});
28 let remove_btn
= Ext
.create('Proxmox.button.StdRemoveButton', {
30 baseurl
: '/access/users/',
32 enableFn
: rec
=> caps
.access
['User.Modify'] && rec
.data
.userid
!== 'root@pam',
33 callback
: () => reload(),
35 let run_editor = function() {
36 var rec
= sm
.getSelection()[0];
37 if (!rec
|| !caps
.access
['User.Modify']) {
40 Ext
.create('PVE.dc.UserEdit', {
41 userid
: rec
.data
.userid
,
44 destroy
: () => reload(),
48 let edit_btn
= new Proxmox
.button
.Button({
49 text
: gettext('Edit'),
51 enableFn: function(rec
) {
52 return !!caps
.access
['User.Modify'];
57 let pwchange_btn
= new Proxmox
.button
.Button({
58 text
: gettext('Password'),
61 enableFn: function(record
) {
62 let type
= record
.data
['realm-type'];
64 if (PVE
.Utils
.authSchema
[type
]) {
65 return !!PVE
.Utils
.authSchema
[type
].pwchange
;
70 handler: function(btn
, event
, rec
) {
71 Ext
.create('Proxmox.window.PasswordEdit', {
72 userid
: rec
.data
.userid
,
75 destroy
: () => reload(),
81 var perm_btn
= new Proxmox
.button
.Button({
82 text
: gettext('Permissions'),
85 handler: function(btn
, event
, rec
) {
86 Ext
.create('PVE.dc.PermissionView', {
87 userid
: rec
.data
.userid
,
90 destroy
: () => reload(),
96 let unlock_btn
= new Proxmox
.button
.Button({
97 text
: gettext('Unlock TFA'),
100 enableFn
: rec
=> !!(caps
.access
['User.Modify'] &&
101 (rec
.data
['totp-locked'] || rec
.data
['tfa-locked-until'])),
102 handler: function(btn
, event
, rec
) {
104 gettext(Ext
.String
.format('Unlock TFA authentication for {0}', rec
.data
.userid
)),
105 gettext("Locked 2nd factors can happen if the user's password was leaked. Are you sure you want to unlock the user?"),
106 function(btn_response
) {
107 if (btn_response
=== 'yes') {
108 Proxmox
.Utils
.API2Request({
109 url
: `/access/users/${rec.data.userid}/unlock-tfa`,
112 failure: function(response
, options
) {
113 Ext
.Msg
.alert(gettext('Error'), response
.htmlStatus
);
115 success: function(response
, options
) {
130 text
: gettext('Add'),
131 disabled
: !caps
.access
['User.Modify'],
132 handler: function() {
133 Ext
.create('PVE.dc.UserEdit', {
136 destroy
: () => reload(),
156 header
: gettext('User name'),
159 renderer
: Proxmox
.Utils
.render_username
,
163 header
: gettext('Realm'),
166 renderer
: Proxmox
.Utils
.render_realm
,
170 header
: gettext('Enabled'),
173 renderer
: Proxmox
.Utils
.format_boolean
,
177 header
: gettext('Expire'),
180 renderer
: Proxmox
.Utils
.format_expire
,
184 header
: gettext('Name'),
187 renderer
: PVE
.Utils
.render_full_name
,
188 dataIndex
: 'firstname',
194 renderer: function(v
, metaData
, record
) {
195 let tfa_type
= PVE
.Parser
.parseTfaType(v
);
196 if (tfa_type
=== undefined) {
197 return Proxmox
.Utils
.noText
;
200 if (tfa_type
!== 1) {
204 let locked_until
= record
.data
['tfa-locked-until'];
205 if (locked_until
!== undefined) {
206 let now
= new Date().getTime() / 1000;
207 if (locked_until
> now
) {
208 return gettext('Locked');
212 if (record
.data
['totp-locked']) {
213 return gettext('TOTP Locked');
216 return Proxmox
.Utils
.yesText
;
221 header
: gettext('Comment'),
223 renderer
: Ext
.String
.htmlEncode
,
224 dataIndex
: 'comment',
230 itemdblclick
: run_editor
,
236 Proxmox
.Utils
.monStoreErrors(me
, store
);