]>
git.proxmox.com Git - pve-manager.git/blob - www/mobile/Login.js
1 Ext
.define('PVE.Login', {
2 extend
: 'Ext.form.Panel',
3 alias
: "widget.pveLogin",
5 handleTFA: function(username
, ticketResponse
) {
7 let errlabel
= me
.down('#signInFailedLabel');
9 // set auth cookie with half-loggedin ticket for TFA
10 ticketResponse
.LoggedOut
= true;
11 Proxmox
.Utils
.setAuthData(ticketResponse
);
13 if (Ext
.isDefined(ticketResponse
.U2FChallenge
)) {
15 title
: 'Error - U2F not implemented',
16 message
: 'The U2F two factor authentication is not yet implemented on mobile.',
17 buttons
: Ext
.MessageBox
.CANCEL
,
22 title
: 'Two-Factor Authentication',
23 message
: 'Please enter your OTP verification code:',
24 buttons
: Ext
.MessageBox
.OKCANCEL
,
28 fn: function(buttonId
, code
) {
29 if (buttonId
=== "cancel") {
30 Proxmox
.LoggedOut
= false;
31 Proxmox
.Utils
.authClear();
35 message
: 'Loading...',
37 Proxmox
.Utils
.API2Request({
38 url
: '/api2/extjs/access/tfa',
39 params
: { response
: code
},
41 timeout
: 5000, // it'll delay both success & failure
42 success: function(resp
, opts
) {
44 // Fill in what we copy over from the 1st factor:
45 let authdata
= resp
.result
.data
;
46 authdata
.CSRFPreventionToken
= Proxmox
.CSRFPreventionToken
;
47 authdata
.username
= username
;
48 // Finish login, sets real cookie and loads page
49 PVE
.Workspace
.updateLoginData(authdata
);
51 failure: function(resp
, opts
) {
53 Proxmox
.Utils
.authClear();
70 src
: '/pve2/images/proxmox_logo.png',
76 title
: 'Proxmox VE Login',
80 placeHolder
: gettext('User name'),
81 itemId
: 'userNameTextField',
86 xtype
: 'passwordfield',
87 placeHolder
: gettext('Password'),
88 itemId
: 'passwordTextField',
93 xtype
: 'pveRealmSelector',
94 itemId
: 'realmSelectorField',
101 html
: 'Login failed. Please enter the correct credentials.',
102 itemId
: 'signInFailedLabel',
104 hideAnimation
: 'fadeOut',
105 showAnimation
: 'fadeIn',
106 style
: 'color:#990000;margin:5px 0px;',
110 itemId
: 'logInButton',
113 handler: function() {
114 var form
= this.up('formpanel');
116 var usernameField
= form
.down('#userNameTextField'),
117 passwordField
= form
.down('#passwordTextField'),
118 realmField
= form
.down('#realmSelectorField'),
119 errlabel
= form
.down('#signInFailedLabel');
123 var username
= usernameField
.getValue();
124 var password
= passwordField
.getValue();
125 var realm
= realmField
.getValue();
127 Proxmox
.Utils
.API2Request({
128 url
: '/access/ticket',
131 params
: { username
: username
, password
: password
, realm
: realm
},
132 failure: function(response
, options
) {
135 success: function(response
, options
) {
136 passwordField
.setValue('');
138 let data
= response
.result
.data
;
139 if (Ext
.isDefined(data
.NeedTFA
)) {
140 form
.handleTFA(username
, data
);
142 PVE
.Workspace
.updateLoginData(data
);
152 Ext
.define('PVE.field.TFACode', {
153 extend
: 'Ext.field.Text',