]>
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' });
38 Proxmox
.Utils
.checked_command(function() {}); // display subscription status
40 failure: function(form
, action
) {
44 gettext('Login failed. Please try again')
50 submitForm: function() {
52 var loginForm
= me
.lookupReference('loginForm');
54 if (loginForm
.isValid()) {
55 loginForm
.mask(gettext('Please wait...'), 'x-mask-loading');
57 success: function(form
, action
) {
58 // save login data and create cookie
59 PMG
.Utils
.updateLoginData(action
.result
.data
);
60 // change view to mainview
61 me
.getView().destroy();
63 if (location
.pathname
=== "/quarantine") {
64 Ext
.create({ xtype
: 'quarantineview' });
65 PMG
.view
= 'quarantine';
67 Ext
.create({ xtype
: 'mainview' });
70 Proxmox
.Utils
.checked_command(function() {}); // display subscription status
72 failure: function(form
, action
) {
76 gettext('Login failed. Please try again')
85 change: function(f
, value
) {
86 var dt
= Ext
.Date
.add(new Date(), Ext
.Date
.YEAR
, 10);
87 Ext
.util
.Cookies
.set('ProxmoxLangCookie', value
, dt
);
88 this.getView().mask(gettext('Please wait...'), 'x-mask-loading');
89 window
.location
.reload();
92 'button[reference=loginButton]': {
118 xtype
: 'versioninfo',
130 reference
: 'loginwindow',
134 defaultFocus
: 'usernameField',
140 title
: gettext('Proxmox Mail Gateway Login'),
148 defaultButton
: 'loginButton',
149 url
: '/api2/extjs/access/ticket',
150 reference
: 'loginForm',
160 fieldLabel
: gettext('User name'),
162 itemId
: 'usernameField',
163 reference
: 'usernameField'
167 inputType
: 'password',
168 fieldLabel
: gettext('Password'),
170 reference
: 'passwordField'
173 xtype
: 'proxmoxLanguageSelector',
174 fieldLabel
: gettext('Language'),
175 value
: Ext
.util
.Cookies
.get('ProxmoxLangCookie') || 'en',
180 xtype
: 'hiddenfield',
187 text
: gettext('Login'),
188 reference
: 'loginButton',