mirror of
https://git.proxmox.com/git/pve-http-server
synced 2025-05-03 14:36:20 +00:00
Formatter/Bootstrap.pm; use configured cookie_name
This commit is contained in:
parent
fc87cd5ec3
commit
6189d2ef0a
@ -6,17 +6,12 @@ use URI::Escape;
|
|||||||
use HTML::Entities;
|
use HTML::Entities;
|
||||||
use JSON;
|
use JSON;
|
||||||
|
|
||||||
# FIXME: cookie_name
|
# FIXME: remove console code??
|
||||||
# FIXME: console code??
|
|
||||||
|
|
||||||
# Helpers to generate simple html pages using Bootstrap markup.
|
# Helpers to generate simple html pages using Bootstrap markup.
|
||||||
|
|
||||||
my $jssrc = <<_EOJS;
|
my $jssrc = <<_EOJS;
|
||||||
PVE = {
|
PVE.open_vm_console = function(node, vmid) {
|
||||||
delete_auth_cookie: function() {
|
|
||||||
document.cookie = "PVEAuthCookie=; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/; secure;";
|
|
||||||
},
|
|
||||||
open_vm_console: function(node, vmid) {
|
|
||||||
console.log("open vm " + vmid + " on node " + node);
|
console.log("open vm " + vmid + " on node " + node);
|
||||||
|
|
||||||
var downloadWithName = function(uri, name) {
|
var downloadWithName = function(uri, name) {
|
||||||
@ -60,7 +55,6 @@ PVE = {
|
|||||||
downloadWithName(url, "pve-spice.vv");
|
downloadWithName(url, "pve-spice.vv");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
_EOJS
|
_EOJS
|
||||||
|
|
||||||
@ -70,6 +64,7 @@ sub new {
|
|||||||
my $self = bless {
|
my $self = bless {
|
||||||
url => $url,
|
url => $url,
|
||||||
title => $title,
|
title => $title,
|
||||||
|
cookie_name => $auth->{cookie_name},
|
||||||
js => '',
|
js => '',
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -83,12 +78,19 @@ sub new {
|
|||||||
sub body {
|
sub body {
|
||||||
my ($self, $html) = @_;
|
my ($self, $html) = @_;
|
||||||
|
|
||||||
my $jssetup = '';
|
my $jssetup = "PVE = {};\n\n"; # create namespace
|
||||||
|
|
||||||
if ($self->{csrftoken}) {
|
if ($self->{csrftoken}) {
|
||||||
$jssetup .= "PVE.CSRFPreventionToken = '$self->{csrftoken}';\n";
|
$jssetup .= "PVE.CSRFPreventionToken = '$self->{csrftoken}';\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$jssetup .= "PVE.delete_auth_cookie = function() {\n";
|
||||||
|
|
||||||
|
if ($self->{cookie_name}) {
|
||||||
|
$jssetup .= " document.cookie = \"$self->{cookie_name}=; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/; secure;\";\n";
|
||||||
|
};
|
||||||
|
$jssetup .= "};\n";
|
||||||
|
|
||||||
return <<_EOD;
|
return <<_EOD;
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
@ -102,8 +104,8 @@ sub body {
|
|||||||
<link href="/css/bootstrap.min.css" rel="stylesheet">
|
<link href="/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$jssrc
|
|
||||||
$jssetup
|
$jssetup
|
||||||
|
$jssrc
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
Loading…
Reference in New Issue
Block a user