]>
git.proxmox.com Git - pmg-gui.git/blob - js/LoginView.js
3441a3df90656274bd21706a0427db060bad9425
2 Ext
.define('PMG.LoginView', {
3 extend
: 'Ext.container.Container',
7 xclass
: 'Ext.app.ViewController',
11 var loginForm
= this.lookupReference('loginForm');
13 // try autologin with quarantine ticket from URL
15 var qs
= Ext
.Object
.fromQueryString(location
.search
);
16 if (qs
.ticket
== undefined) { return; }
17 var ticket
= decodeURIComponent(qs
.ticket
);
18 var match
= ticket
.match(/^PMGQUAR:([^\s\:]+):/);
19 if (!match
) { return; }
20 var username
= match
[1];
21 var loginwin
= me
.lookup('loginwindow');
22 loginwin
.autoShow
= false;
23 loginwin
.setVisible(false);
25 me
.lookup('usernameField').setValue(username
);
26 me
.lookup('passwordField').setValue(ticket
);
31 submitForm: function() {
33 var view
= me
.getView();
34 var loginForm
= me
.lookupReference('loginForm');
36 if (loginForm
.isValid()) {
37 if (loginForm
.isVisible()) {
38 loginForm
.mask(gettext('Please wait...'), 'x-mask-loading');
41 success: function(form
, action
) {
42 // save login data and create cookie
43 PMG
.Utils
.updateLoginData(action
.result
.data
);
44 PMG
.app
.changeView(view
.targetview
);
46 failure: function(form
, action
) {
50 gettext('Login failed. Please try again')
59 change: function(f
, value
) {
60 var dt
= Ext
.Date
.add(new Date(), Ext
.Date
.YEAR
, 10);
61 Ext
.util
.Cookies
.set('PMGLangCookie', value
, dt
);
63 var loginwin
= this.lookupReference('loginwindow');
64 loginwin
.mask(gettext('Please wait...'), 'x-mask-loading');
65 window
.location
.reload();
68 'button[reference=loginButton]': {
107 reference
: 'loginwindow',
111 defaultFocus
: 'usernameField',
117 title
: gettext('Proxmox Mail Gateway Login'),
125 defaultButton
: 'loginButton',
126 url
: '/api2/extjs/access/ticket',
127 reference
: 'loginForm',
137 fieldLabel
: gettext('User name'),
139 itemId
: 'usernameField',
140 reference
: 'usernameField'
144 inputType
: 'password',
145 fieldLabel
: gettext('Password'),
147 reference
: 'passwordField'
150 xtype
: 'proxmoxLanguageSelector',
151 fieldLabel
: gettext('Language'),
152 value
: Ext
.util
.Cookies
.get('PMGLangCookie') || 'en',
157 xtype
: 'hiddenfield',
164 text
: gettext('Login'),
165 reference
: 'loginButton',