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', {
name: 'password',
required: true
},
{
xtype: 'textfield',
itemId: 'otpField',
placeHolder: gettext('OTP'),
name: 'otp',
allowBlank: false,
hidden: true
},
{
xtype: 'pveRealmSelector',
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', {
var usernameField = form.down('#userNameTextField'),
passwordField = form.down('#passwordTextField'),
realmField = form.down('#realmSelectorField'),
otpField = form.down('#otpField'),
label = form.down('#signInFailedLabel');
label.hide();
......@@ -64,12 +88,13 @@ Ext.define('PVE.Login', {
var username = usernameField.getValue();
var password = passwordField.getValue();
var realm = realmField.getValue();
var otp = otpField.getValue();
PVE.Utils.API2Request({
url: '/access/ticket',
method: 'POST',
waitMsgTarget: form,
params: { username: username, password: password, realm: realm },
params: { username: username, password: password, realm: realm, otp: otp},
failure: function(response, options) {
label.show();
},
......
......@@ -13,7 +13,9 @@ Ext.define('PVE.form.RealmSelector', {
needOTP: function(realm) {
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;
},
......
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