forked from lix-project/hydra
Add a flag to enable Persona support
It's disabled by default. To enable, add the following to hydra.conf: enable_persona = 1
This commit is contained in:
parent
d118a575e1
commit
b44baf3746
6 changed files with 28 additions and 15 deletions
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -101,11 +101,13 @@
|
|||
|
||||
<script>
|
||||
function doLogout() {
|
||||
[% IF c.user_exists %]
|
||||
$.post("[% c.uri_for('/logout') %]")
|
||||
.done(function(data) {
|
||||
window.location.reload();
|
||||
})
|
||||
.fail(function() { bootbox.alert("Server request failed!"); });
|
||||
[% END %]
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -123,6 +123,7 @@
|
|||
<a href="#" id="persona-signout">Sign out</a>
|
||||
</li>
|
||||
[% ELSE %]
|
||||
[% IF personaEnabled %]
|
||||
[% WRAPPER makeSubMenu title="Sign in" %]
|
||||
<li>
|
||||
<a href="#" id="persona-signin">
|
||||
|
@ -134,6 +135,11 @@
|
|||
<a href="#hydra-signin" data-toggle="modal">Sign in with a Hydra account</a>
|
||||
</li>
|
||||
[% END %]
|
||||
[% ELSE %]
|
||||
<li>
|
||||
<a href="#hydra-signin" data-toggle="modal">Sign in</a>
|
||||
</li>
|
||||
[% END %]
|
||||
[% END %]
|
||||
|
||||
</ul>
|
||||
|
|
Loading…
Reference in a new issue