diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index cbdba121..9ca2c81a 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -24,6 +24,7 @@ sub begin :Private { $c->stash->{tracker} = $ENV{"HYDRA_TRACKER"}; $c->stash->{flashMsg} = $c->flash->{flashMsg}; $c->stash->{successMsg} = $c->flash->{successMsg}; + $c->stash->{personaEnabled} = $c->config->{enable_persona} // "0" eq "1"; if (scalar(@args) == 0 || $args[0] ne "static") { $c->stash->{nrRunningBuilds} = $c->model('DB::Builds')->search({ finished => 0, busy => 1 }, {})->count(); diff --git a/src/lib/Hydra/Controller/User.pm b/src/lib/Hydra/Controller/User.pm index 66b645b2..024ddd2f 100644 --- a/src/lib/Hydra/Controller/User.pm +++ b/src/lib/Hydra/Controller/User.pm @@ -48,6 +48,8 @@ sub persona_login :Path('/persona-login') Args(0) { my ($self, $c) = @_; requirePost($c); + error($c, "Persona support is not enabled.") unless $c->stash->{personaEnabled}; + my $assertion = $c->req->params->{assertion} or die; my $ua = new LWP::UserAgent; diff --git a/src/root/layout.tt b/src/root/layout.tt index 074e4809..933fe893 100644 --- a/src/root/layout.tt +++ b/src/root/layout.tt @@ -101,11 +101,13 @@ @@ -124,7 +126,8 @@ url: "[% c.uri_for('/persona-login') %]", data: "assertion=" + assertion, type: 'POST', - success: function(data) { window.location.reload(); } + success: function(data) { window.location.reload(); }, + postError: function() { navigator.id.logout(); } }); }, onlogout: doLogout diff --git a/src/root/static/css/hydra.css b/src/root/static/css/hydra.css index b369f3e0..6f65c649 100644 --- a/src/root/static/css/hydra.css +++ b/src/root/static/css/hydra.css @@ -107,4 +107,4 @@ td.nowrap { .star:hover { cursor: pointer; -} \ No newline at end of file +} diff --git a/src/root/static/js/common.js b/src/root/static/js/common.js index 784c2ed3..68a65d2a 100644 --- a/src/root/static/js/common.js +++ b/src/root/static/js/common.js @@ -135,6 +135,7 @@ function requestJSON(args) { bootbox.alert("Server error: " + escapeHTML(data.responseText)); else bootbox.alert("Unknown server error!"); + if (args.postError) args.postError(data); }; return $.ajax(args); }; diff --git a/src/root/topbar.tt b/src/root/topbar.tt index 80895e67..6e3cd264 100644 --- a/src/root/topbar.tt +++ b/src/root/topbar.tt @@ -123,15 +123,21 @@ Sign out [% ELSE %] - [% WRAPPER makeSubMenu title="Sign in" %] + [% IF personaEnabled %] + [% WRAPPER makeSubMenu title="Sign in" %] +
  • + + Sign in with Persona + +
  • +
  • +
  • + Sign in with a Hydra account +
  • + [% END %] + [% ELSE %]
  • - - Sign in with Persona - -
  • -
  • -
  • - Sign in with a Hydra account + Sign in
  • [% END %] [% END %]