From 1db938147399020c933f234f55236fe21acb2cba Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 9 Jul 2013 13:55:44 +0200 Subject: [PATCH] Fix legacy login --- src/lib/Hydra/Controller/User.pm | 24 ++--------- src/root/layout.tt | 70 ++++++++++++++++++-------------- src/root/login.tt | 7 +--- 3 files changed, 45 insertions(+), 56 deletions(-) diff --git a/src/lib/Hydra/Controller/User.pm b/src/lib/Hydra/Controller/User.pm index bcfe0685..6a11c231 100644 --- a/src/lib/Hydra/Controller/User.pm +++ b/src/lib/Hydra/Controller/User.pm @@ -58,18 +58,9 @@ sub logout :Local :Args(0) :ActionClass('REST::ForBrowsers') { } sub logout_POST { my ($self, $c) = @_; + $c->flash->{flashMsg} = "You are no longer signed in." if $c->user_exists(); $c->logout; - if ($c->request->looks_like_browser) { - $c->response->redirect($c->request->referer || $c->uri_for('/')); - } else { - $self->status_no_content($c); - } -} - -sub logout_GET { - # Probably a better way to do this - my ($self, $c) = @_; - logout_POST($self, $c); + $self->status_no_content($c); } @@ -107,16 +98,7 @@ sub persona_login :Path('/persona-login') Args(0) { $c->set_authenticated($user); $c->stash->{json}->{result} = "ok"; - $c->flash->{successMsg} = "You are now signed in as " . encode_entities($email) . ""; -} - - -sub persona_logout :Path('/persona-logout') Args(0) { - my ($self, $c) = @_; - $c->stash->{json} = {}; - requirePost($c); - $c->flash->{flashMsg} = "You are no longer signed in." if $c->user_exists(); - $c->logout; + $c->flash->{successMsg} = "You are now signed in as " . encode_entities($email) . "."; } diff --git a/src/root/layout.tt b/src/root/layout.tt index 23327338..ed255e05 100644 --- a/src/root/layout.tt +++ b/src/root/layout.tt @@ -102,39 +102,49 @@ - - + [% IF c.user_exists && c.user.password != '!' %] + + [% ELSE %] + + + + [% END %] + diff --git a/src/root/login.tt b/src/root/login.tt index bf3ad616..d26cb4d6 100644 --- a/src/root/login.tt +++ b/src/root/login.tt @@ -2,9 +2,8 @@ [% PROCESS common.tt %] [% IF c.user_exists %] -

-You are already logged in as [% c.user.username %]. -You can logout here. +

+You are already signed in as [% HTML.escape(c.user.username) %].

[% ELSE %] @@ -13,7 +12,6 @@ You can logout here. c.uri_for('/register') %]">register first.

--> - [% END %]