]>
git.proxmox.com Git - pmg-gui.git/blob - js/LoginView.js
2 Ext
.define('PMG.LoginView', {
3 extend
: 'Ext.container.Container',
7 xclass
: 'Ext.app.ViewController',
10 var loginForm
= this.lookupReference('loginForm');
12 // try autologin with quarantine ticket from URL
14 var qs
= Ext
.Object
.fromQueryString(location
.search
);
15 if (qs
.ticket
== undefined) { return; }
16 var ticket
= decodeURIComponent(qs
.ticket
);
17 var match
= ticket
.match(/^PMGQUAR:([^\s\:]+):/);
18 if (!match
) { return; }
19 var username
= match
[1];
20 var loginwin
= this.lookupReference('loginwindow');
21 loginwin
.autoShow
= false;
22 loginwin
.setVisible(false);
24 Proxmox
.Utils
.API2Request({
25 url
: '/api2/extjs/access/ticket',
31 success: function(response
) {
32 // save login data and create cookie
33 PMG
.Utils
.updateLoginData(response
.result
.data
);
34 // change view to mainview
36 PMG
.view
= 'quarantine';
37 Ext
.create({ xtype
: 'quarantineview' });
39 failure: function(form
, action
) {
43 gettext('Login failed. Please try again')
49 submitForm: function() {
51 var loginForm
= me
.lookupReference('loginForm');
53 if (loginForm
.isValid()) {
54 loginForm
.mask(gettext('Please wait...'), 'x-mask-loading');
56 success: function(form
, action
) {
57 // save login data and create cookie
58 PMG
.Utils
.updateLoginData(action
.result
.data
);
59 // change view to mainview
60 me
.getView().destroy();
62 if (location
.pathname
=== "/quarantine") {
63 Ext
.create({ xtype
: 'quarantineview' });
64 PMG
.view
= 'quarantine';
66 Ext
.create({ xtype
: 'mainview' });
70 failure: function(form
, action
) {
74 gettext('Login failed. Please try again')
82 'button[reference=loginButton]': {
108 xtype
: 'versioninfo',
120 reference
: 'loginwindow',
124 defaultFocus
: 'usernameField',
130 title
: gettext('Proxmox Mail Gateway Login'),
138 defaultButton
: 'loginButton',
139 url
: '/api2/extjs/access/ticket',
140 reference
: 'loginForm',
150 fieldLabel
: gettext('User name'),
152 itemId
: 'usernameField',
153 reference
: 'usernameField'
157 inputType
: 'password',
158 fieldLabel
: gettext('Password'),
160 reference
: 'passwordField'
163 xtype
: 'hiddenfield',
170 text
: gettext('Login'),
171 reference
: 'loginButton',