Commit 10f7ed8d authored by Dietmar Maurer's avatar Dietmar Maurer

add support for two factor auth

parent 16bef583
......@@ -32,7 +32,7 @@ Ext.define('PVE.RestProxy', {
Ext.define('pve-domains', {
extend: "Ext.data.Model",
fields: [ 'realm', 'type', 'comment', 'default',
fields: [ 'realm', 'type', 'comment', 'default', 'tfa',
{
name: 'descr',
// Note: We use this in the RealmComboBox.js
......@@ -45,7 +45,13 @@ Ext.define('PVE.RestProxy', {
return value;
}
// return realm if there is no comment
return info.comment || info.realm;
text = info.comment || info.realm;
if (info.tfa) {
text += " (+ " + info.tfa + ")";
}
return text;
}
}
],
......
......@@ -118,11 +118,19 @@ Ext.define('PVE.dc.UserEdit', {
name: 'email',
fieldLabel: gettext('E-Mail'),
vtype: 'email'
},
}
];
var columnB = [
{
xtype: 'textfield',
name: 'comment',
fieldLabel: gettext('Comment')
},
{
xtype: 'textfield',
name: 'keys',
fieldLabel: gettext('Key IDs')
}
];
......@@ -147,6 +155,7 @@ Ext.define('PVE.dc.UserEdit', {
var ipanel = Ext.create('PVE.panel.InputPanel', {
column1: column1,
column2: column2,
columnB: columnB,
onGetValues: function(values) {
// hack: ExtJS datefield does not submit 0, so we need to set that
if (!values.expire) {
......
......@@ -2,6 +2,14 @@ Ext.define('PVE.form.RealmComboBox', {
extend: 'Ext.form.field.ComboBox',
alias: ['widget.pveRealmComboBox'],
needOTP: function(realm) {
var me = this;
var rec = me.store.findRecord('realm', realm);
return rec && rec.data && rec.data.tfa ? rec.data.tfa : undefined;
},
initComponent: function() {
var me = this;
......
......@@ -34,6 +34,13 @@ Ext.define('PVE.window.LoginWindow', {
initComponent: function() {
var me = this;
var otp_field = Ext.createWidget('textfield', {
fieldLabel: gettext('OTP'),
name: 'otp',
allowBlank: false,
hidden: true
});
Ext.apply(me, {
width: 400,
modal: true,
......@@ -95,9 +102,21 @@ Ext.define('PVE.window.LoginWindow', {
}
}
},
otp_field,
{
xtype: 'pveRealmComboBox',
name: 'realm'
name: 'realm',
listeners: {
change: function(f, value) {
if (f.needOTP(value)) {
otp_field.setVisible(true);
otp_field.setDisabled(false);
} else {
otp_field.setVisible(false);
otp_field.setDisabled(true);
}
}
}
},
{
xtype: 'pveLanguageSelector',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment