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:
Eelco Dolstra
2013-11-06 14:38:36 +01:00
parent d118a575e1
commit b44baf3746
6 changed files with 28 additions and 15 deletions

View File

@ -101,11 +101,13 @@
<script>
function doLogout() {
$.post("[% c.uri_for('/logout') %]")
.done(function(data) {
window.location.reload();
})
.fail(function() { bootbox.alert("Server request failed!"); });
[% 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

View File

@ -107,4 +107,4 @@ td.nowrap {
.star:hover {
cursor: pointer;
}
}

View File

@ -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);
};

View File

@ -123,15 +123,21 @@
<a href="#" id="persona-signout">Sign out</a>
</li>
[% ELSE %]
[% WRAPPER makeSubMenu title="Sign in" %]
[% IF personaEnabled %]
[% WRAPPER makeSubMenu title="Sign in" %]
<li>
<a href="#" id="persona-signin">
<img src="https://developer.mozilla.org/files/3963/persona_sign_in_blue.png" alt="Sign in with Persona" />
</a>
</li>
<li class="divider"></li>
<li>
<a href="#hydra-signin" data-toggle="modal">Sign in with a Hydra account</a>
</li>
[% END %]
[% ELSE %]
<li>
<a href="#" id="persona-signin">
<img src="https://developer.mozilla.org/files/3963/persona_sign_in_blue.png" alt="Sign in with Persona" />
</a>
</li>
<li class="divider"></li>
<li>
<a href="#hydra-signin" data-toggle="modal">Sign in with a Hydra account</a>
<a href="#hydra-signin" data-toggle="modal">Sign in</a>
</li>
[% END %]
[% END %]