Commit a1eafd66 authored by Dietmar Maurer's avatar Dietmar Maurer

mobile: implement two factor auth

parent 9940ea01
...@@ -30,10 +30,33 @@ Ext.define('PVE.Login', { ...@@ -30,10 +30,33 @@ Ext.define('PVE.Login', {
name: 'password', name: 'password',
required: true required: true
}, },
{
xtype: 'textfield',
itemId: 'otpField',
placeHolder: gettext('OTP'),
name: 'otp',
allowBlank: false,
hidden: true
},
{ {
xtype: 'pveRealmSelector', xtype: 'pveRealmSelector',
itemId: 'realmSelectorField', itemId: 'realmSelectorField',
name: 'realm' name: 'realm',
listeners: {
change: function(f, value) {
var form = this.up('formpanel');
var otp_field = form.down('#otpField');
if (f.needOTP(value)) {
otp_field.setHidden(false);
otp_field.enable();
} else {
otp_field.setHidden(true);
otp_field.disable();
}
}
}
} }
] ]
}, },
...@@ -57,6 +80,7 @@ Ext.define('PVE.Login', { ...@@ -57,6 +80,7 @@ Ext.define('PVE.Login', {
var usernameField = form.down('#userNameTextField'), var usernameField = form.down('#userNameTextField'),
passwordField = form.down('#passwordTextField'), passwordField = form.down('#passwordTextField'),
realmField = form.down('#realmSelectorField'), realmField = form.down('#realmSelectorField'),
otpField = form.down('#otpField'),
label = form.down('#signInFailedLabel'); label = form.down('#signInFailedLabel');
label.hide(); label.hide();
...@@ -64,12 +88,13 @@ Ext.define('PVE.Login', { ...@@ -64,12 +88,13 @@ Ext.define('PVE.Login', {
var username = usernameField.getValue(); var username = usernameField.getValue();
var password = passwordField.getValue(); var password = passwordField.getValue();
var realm = realmField.getValue(); var realm = realmField.getValue();
var otp = otpField.getValue();
PVE.Utils.API2Request({ PVE.Utils.API2Request({
url: '/access/ticket', url: '/access/ticket',
method: 'POST', method: 'POST',
waitMsgTarget: form, waitMsgTarget: form,
params: { username: username, password: password, realm: realm }, params: { username: username, password: password, realm: realm, otp: otp},
failure: function(response, options) { failure: function(response, options) {
label.show(); label.show();
}, },
......
...@@ -13,7 +13,9 @@ Ext.define('PVE.form.RealmSelector', { ...@@ -13,7 +13,9 @@ Ext.define('PVE.form.RealmSelector', {
needOTP: function(realm) { needOTP: function(realm) {
var me = this; var me = this;
var rec = me.store.findRecord('realm', realm); var realmstore = me.getStore();
var rec = realmstore.findRecord('realm', realm);
return rec && rec.data && rec.data.tfa ? rec.data.tfa : undefined; return rec && rec.data && rec.data.tfa ? rec.data.tfa : undefined;
}, },
......
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