mirror of
https://git.proxmox.com/git/pmg-gui
synced 2025-08-17 21:42:43 +00:00
js/LoginView.js: implement autologin with quarantine tickets
This commit is contained in:
parent
b045f069ab
commit
4bc1cbd8b3
@ -4,6 +4,43 @@ Ext.define('PMG.LoginView', {
|
|||||||
|
|
||||||
controller: {
|
controller: {
|
||||||
xclass: 'Ext.app.ViewController',
|
xclass: 'Ext.app.ViewController',
|
||||||
|
|
||||||
|
init: function(view) {
|
||||||
|
var loginForm = this.lookupReference('loginForm');
|
||||||
|
|
||||||
|
// try autologin with quarantine ticket from URL
|
||||||
|
|
||||||
|
var qs = Ext.Object.fromQueryString(location.search);
|
||||||
|
if (qs.ticket == undefined) { return; }
|
||||||
|
var ticket = decodeURIComponent(qs.ticket);
|
||||||
|
var match = ticket.match(/^PMGQUAR:([^\s\:]+):/);
|
||||||
|
if (!match) { return; }
|
||||||
|
var username = match[1];
|
||||||
|
|
||||||
|
Proxmox.Utils.API2Request({
|
||||||
|
url: '/api2/extjs/access/ticket',
|
||||||
|
params: {
|
||||||
|
username: username,
|
||||||
|
password: ticket
|
||||||
|
},
|
||||||
|
method: 'POST',
|
||||||
|
success: function(response) {
|
||||||
|
// save login data and create cookie
|
||||||
|
PMG.Utils.updateLoginData(response.result.data);
|
||||||
|
// change view to mainview
|
||||||
|
view.destroy();
|
||||||
|
Ext.create({ xtype: 'mainview' });
|
||||||
|
},
|
||||||
|
failure: function(form, action) {
|
||||||
|
loginForm.unmask();
|
||||||
|
Ext.MessageBox.alert(
|
||||||
|
gettext('Error'),
|
||||||
|
gettext('Login failed. Please try again')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
submitForm: function() {
|
submitForm: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
var loginForm = me.lookupReference('loginForm');
|
var loginForm = me.lookupReference('loginForm');
|
||||||
|
Loading…
Reference in New Issue
Block a user