Skip to content

Commit

Permalink
Merge pull request #1854 from metacpan/leo/no_cache_account
Browse files Browse the repository at this point in the history
Leo/no cache account
  • Loading branch information
ranguard committed Feb 22, 2017
2 parents d021750 + 1be21de commit 63fcda1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 1 addition & 3 deletions lib/MetaCPAN/Web/Controller/Account.pm
Expand Up @@ -9,9 +9,7 @@ BEGIN { extends 'MetaCPAN::Web::Controller' }
sub auto : Private {
my ( $self, $c ) = @_;

# Keep everything here as specific to the user
# this is for proxies
$c->res->header( Vary => 'Cookie' );
$c->cdn_never_cache(1);

if ( my $token = $c->token ) {
$c->authenticate( { token => $token } );
Expand Down
8 changes: 8 additions & 0 deletions lib/MetaCPAN/Web/Controller/Login.pm
Expand Up @@ -7,6 +7,10 @@ BEGIN { extends 'MetaCPAN::Web::Controller' }

sub index : Path : Args(0) {
my ( $self, $c ) = @_;

# Never cache at CDN
$c->cdn_never_cache(1);

if ( my $code = $c->req->parameters->{code} ) {
my $data = $c->model('API')->request(
'/oauth2/access_token',
Expand All @@ -29,6 +33,10 @@ sub index : Path : Args(0) {

sub openid : Local : Args(0) {
my ( $self, $c ) = @_;

# Never cache at CDN
$c->cdn_never_cache(1);

$c->stash( { template => 'account/openid-login.html' } );
}

Expand Down
5 changes: 3 additions & 2 deletions t/controller/account.t
Expand Up @@ -36,8 +36,9 @@ test_psgi app, sub {
'GET /account/profile without token'
);
is( $res->code, 403, '... and the user cannot get in' );
is( $res->header('Vary'),
'Cookie', '... and the Vary header for proxies is there' );
is( $res->header('Cache-Control'),
'private',
'... and the private Cache-Control header for proxies is there' );
is( $authenticate_args, undef,
'... and we did not try to authenticate' );

Expand Down

0 comments on commit 63fcda1

Please sign in to comment.