Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Move from CGI::Cookie, which looks at ENV, to plack's way of cookie h…

…andling
  • Loading branch information...
commit 567fd869d43c8b18efb3a73892131991a9e590a6 1 parent db75bb9
@alexmv alexmv authored
Showing with 7 additions and 19 deletions.
  1. +0 −1  Makefile.PL
  2. +7 −18 lib/Jifty/Plugin/Comment/Action/CreateComment.pm
View
1  Makefile.PL
@@ -8,7 +8,6 @@ requires('MIME::Base64::URLSafe');
requires('Regexp::Common');
requires('Regexp::Common::URI');
requires('Regexp::Common::Email::Address');
-requires('CGI::Cookie');
auto_install();
tests('t/*.t t/*/t/*.t');
View
25 lib/Jifty/Plugin/Comment/Action/CreateComment.pm
@@ -158,7 +158,6 @@ use Jifty::Action::Record::Create schema {
;
};
-use CGI::Cookie;
use MIME::Base64::URLSafe;
#use Contentment::Notification::CommentPublished;
#use Contentment::Notification::CommentNeedsModeration;
@@ -208,14 +207,11 @@ sub take_action {
my $email = urlsafe_b64encode(
$self->argument_value('email'));
- my $cookie = CGI::Cookie->new(
- -path => '/',
- -name => 'COMMENT_REMEMBORY',
- -value => join('.', $your_name, $web_site, $email),
- -expires => '+3M',
- );
-
- Jifty->web->response->add_header( 'Set-Cookie' => $cookie->as_string );
+ Jifty->web->response->cookies->{COMMENT_REMEMBORY} = {
+ path => '/',
+ value => join('.', $your_name, $web_site, $email),
+ expires => '+3M',
+ };
$self->SUPER::take_action(@_);
@@ -274,15 +270,8 @@ Creating a comment this way causes a cookie named "COMMENT_REMEMBORY" to be stor
=cut
-my $comment_cookie;
sub fetch_comment_cookie {
- return $comment_cookie if defined $comment_cookie;
-
- my %cookies = CGI::Cookie->fetch;
- $comment_cookie
- = $cookies{'COMMENT_REMEMBORY'} ? $cookies{'COMMENT_REMEMBORY'} : '';
-
- return $comment_cookie;
+ return Jifty->web->request->cookies->{COMMENT_REMEMBORY};
}
=head2 from_cookie
@@ -303,7 +292,7 @@ sub from_cookie {
);
}
- elsif (my $value = eval { fetch_comment_cookie()->value }) {
+ elsif (my $value = fetch_comment_cookie() ) {
my @fields = split /\./, $value;
if (defined $fields[ $pos ]) {
Please sign in to comment.
Something went wrong with that request. Please try again.