]>
git.proxmox.com Git - pmg-gui.git/blob - js/LoginView.js
1 Ext
.define('PMG.LoginView', {
2 extend
: 'Ext.container.Container',
6 xclass
: 'Ext.app.ViewController',
11 var realmfield
= me
.lookup('realmfield');
13 if (view
.targetview
!== 'quarantineview') {
17 realmfield
.setValue('quarantine');
19 // try autologin with quarantine ticket from URL
21 var loginForm
= this.lookupReference('loginForm');
23 var qs
= Ext
.Object
.fromQueryString(location
.search
);
24 if (qs
.ticket
== undefined) { return; }
25 var ticket
= decodeURIComponent(qs
.ticket
);
26 var match
= ticket
.match(/^PMGQUAR:([^\s\:]+):/);
27 if (!match
) { return; }
28 var username
= match
[1];
29 var loginwin
= me
.lookup('loginwindow');
30 loginwin
.autoShow
= false;
31 loginwin
.setVisible(false);
32 realmfield
.setDisabled(true);
34 me
.lookup('usernameField').setValue(username
);
35 me
.lookup('passwordField').setValue(ticket
);
40 submitForm: function() {
42 var view
= me
.getView();
43 var loginForm
= me
.lookupReference('loginForm');
45 if (loginForm
.isValid()) {
46 if (loginForm
.isVisible()) {
47 loginForm
.mask(gettext('Please wait...'), 'x-mask-loading');
50 success: function(form
, action
) {
51 // save login data and create cookie
52 PMG
.Utils
.updateLoginData(action
.result
.data
);
53 PMG
.app
.changeView(view
.targetview
);
55 failure: function(form
, action
) {
59 gettext('Login failed. Please try again')
68 change: function(f
, value
) {
69 var dt
= Ext
.Date
.add(new Date(), Ext
.Date
.YEAR
, 10);
70 Ext
.util
.Cookies
.set('PMGLangCookie', value
, dt
);
72 var loginwin
= this.lookupReference('loginwindow');
73 loginwin
.mask(gettext('Please wait...'), 'x-mask-loading');
74 window
.location
.reload();
77 'button[reference=loginButton]': {
104 xtype
: 'versioninfo',
116 reference
: 'loginwindow',
120 defaultFocus
: 'usernameField',
126 title
: gettext('Proxmox Mail Gateway Login'),
134 defaultButton
: 'loginButton',
135 url
: '/api2/extjs/access/ticket',
136 reference
: 'loginForm',
146 fieldLabel
: gettext('User name'),
148 itemId
: 'usernameField',
149 reference
: 'usernameField'
153 inputType
: 'password',
154 fieldLabel
: gettext('Password'),
156 reference
: 'passwordField'
159 xtype
: 'proxmoxLanguageSelector',
160 fieldLabel
: gettext('Language'),
161 value
: Ext
.util
.Cookies
.get('PMGLangCookie') || 'en',
166 xtype
: 'hiddenfield',
167 reference
: 'realmfield',
174 text
: gettext('Login'),
175 reference
: 'loginButton',