diff --git a/src/lib/Hydra/Controller/User.pm b/src/lib/Hydra/Controller/User.pm index e96796fb..96dd3e30 100644 --- a/src/lib/Hydra/Controller/User.pm +++ b/src/lib/Hydra/Controller/User.pm @@ -46,7 +46,6 @@ sub logout_POST { sub persona_login :Path('/persona-login') Args(0) { my ($self, $c) = @_; - $c->stash->{json} = {}; requirePost($c); my $assertion = $c->req->params->{assertion} or die; @@ -78,7 +77,7 @@ sub persona_login :Path('/persona-login') Args(0) { $c->set_authenticated($user); - $c->stash->{json}->{result} = "ok"; + $self->status_no_content($c); $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 2237e79b..fb4a2531 100644 --- a/src/root/layout.tt +++ b/src/root/layout.tt @@ -124,14 +124,12 @@ navigator.id.watch({ loggedInUser: [% c.user_exists ? '"' _ HTML.escape(c.user.username) _ '"' : "null" %], onlogin: function(assertion) { - $.post("[% c.uri_for('/persona-login') %]", { assertion: assertion }) - .done(function(data) { - if (data.error) - bootbox.alert("Login failed: " + data.error); - else - window.location.reload(); - }) - .fail(function() { bootbox.alert("Server request failed!"); }); + requestJSON({ + url: "[% c.uri_for('/persona-login') %]", + data: "assertion=" + assertion, + type: 'POST', + success: function(data) { window.location.reload(); } + }); }, onlogout: doLogout });