Slight cleanup in the Persona sign in code

This commit is contained in:
Eelco Dolstra 2013-11-05 14:10:20 +01:00
parent bdd6e99fbd
commit 3c981bed02
2 changed files with 7 additions and 10 deletions

View file

@ -46,7 +46,6 @@ sub logout_POST {
sub persona_login :Path('/persona-login') Args(0) { sub persona_login :Path('/persona-login') Args(0) {
my ($self, $c) = @_; my ($self, $c) = @_;
$c->stash->{json} = {};
requirePost($c); requirePost($c);
my $assertion = $c->req->params->{assertion} or die; 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->set_authenticated($user);
$c->stash->{json}->{result} = "ok"; $self->status_no_content($c);
$c->flash->{successMsg} = "You are now signed in as <tt>" . encode_entities($email) . "</tt>."; $c->flash->{successMsg} = "You are now signed in as <tt>" . encode_entities($email) . "</tt>.";
} }

View file

@ -124,14 +124,12 @@
navigator.id.watch({ navigator.id.watch({
loggedInUser: [% c.user_exists ? '"' _ HTML.escape(c.user.username) _ '"' : "null" %], loggedInUser: [% c.user_exists ? '"' _ HTML.escape(c.user.username) _ '"' : "null" %],
onlogin: function(assertion) { onlogin: function(assertion) {
$.post("[% c.uri_for('/persona-login') %]", { assertion: assertion }) requestJSON({
.done(function(data) { url: "[% c.uri_for('/persona-login') %]",
if (data.error) data: "assertion=" + assertion,
bootbox.alert("Login failed: " + data.error); type: 'POST',
else success: function(data) { window.location.reload(); }
window.location.reload(); });
})
.fail(function() { bootbox.alert("Server request failed!"); });
}, },
onlogout: doLogout onlogout: doLogout
}); });