From 10918f3336863623020a6d73e63a0f0a5eebb306 Mon Sep 17 00:00:00 2001 From: Dylan William Hardison Date: Sat, 19 May 2018 00:34:01 -0400 Subject: mojo all the things --- Bugzilla/Quantum/CGI.pm | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'Bugzilla/Quantum/CGI.pm') diff --git a/Bugzilla/Quantum/CGI.pm b/Bugzilla/Quantum/CGI.pm index 34db9a46f..e5db4123f 100644 --- a/Bugzilla/Quantum/CGI.pm +++ b/Bugzilla/Quantum/CGI.pm @@ -63,4 +63,32 @@ sub Vars { return $self->controller->req->query_params->to_hash; } +sub query_string { + my ($self) = @_; + + return $self->controller->req->query_params->to_string; +} + +sub send_cookie { + my ($self, %params) = @_; + my $name = delete $params{'-name'}; + my $value = delete $params{'-value'} or ThrowCodeError('cookies_need_value'); + state $uri = URI->new( Bugzilla->localconfig->{urlbase} ); + my %attrs = ( + path => $uri->path, + secure => lc( $uri->scheme ) eq 'https', + samesite => 'Lax', + ); + my $expires = delete $params{'-expires'}; + $attrs{expires} = $expires if $expires; + $attrs{httponly} = 1 if delete $params{'-httponly'}; + + if (keys %params) { + die "Unknown keys: " . join(", ", keys %params); + } + + $self->controller->cookie($name, $value, \%params); +} + 1; + -- cgit v1.2.3-24-g4f1b