[pve-devel] [PATCH v2 07/10] PVE/API2/Formatter/HTML.pm: avoid use of PVE::REST

Dietmar Maurer dietmar at proxmox.com
Tue Jan 10 17:06:04 CET 2017


Instead, pass the HTTP server as last argument to the page formater,
so that we can call $server->create_auth_cookie().

Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
 PVE/API2/Formatter/HTML.pm | 5 +++--
 PVE/HTTPServer.pm          | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/PVE/API2/Formatter/HTML.pm b/PVE/API2/Formatter/HTML.pm
index 3165088..69c0d97 100644
--- a/PVE/API2/Formatter/HTML.pm
+++ b/PVE/API2/Formatter/HTML.pm
@@ -3,7 +3,6 @@ package PVE::API2::Formatter::HTML;
 use strict;
 use warnings;
 
-use PVE::REST;
 use PVE::HTTPServer;
 use HTTP::Status;
 use JSON;
@@ -267,7 +266,9 @@ PVE::API2->register_page_formatter(
 	my ($res, $data, $param, $path, $auth) = @_;
 
 	if (HTTP::Status::is_success($res->{status})) {
-	    my $cookie = PVE::REST::create_auth_cookie($data->{ticket});
+	    my $cookie = PVE::HTTPServer::create_auth_cookie(
+		$data->{ticket}, $auth->{cookie_name});
+
 	    my $headers = HTTP::Headers->new(Location => $baseurl,
 					     'Set-Cookie' => $cookie);
 	    return HTTP::Response->new(301, "Moved", $headers);
diff --git a/PVE/HTTPServer.pm b/PVE/HTTPServer.pm
index d2ae1fe..10263e9 100755
--- a/PVE/HTTPServer.pm
+++ b/PVE/HTTPServer.pm
@@ -1777,6 +1777,7 @@ sub auth_handler {
 	userid => $username,
 	age => $age,
 	isUpload => $isUpload,
+	cookie_name => $self->{cookie_name},
     };
 }
 
-- 
2.1.4



More information about the pve-devel mailing list