Fix legacy login
This commit is contained in:
@ -102,39 +102,49 @@
|
||||
|
||||
</div>
|
||||
|
||||
<script src="https://login.persona.org/include.js"></script>
|
||||
|
||||
<script>
|
||||
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!"); });
|
||||
},
|
||||
onlogout: function() {
|
||||
$.post("[% c.uri_for('/persona-logout') %]")
|
||||
.done(function(data) {
|
||||
window.location.reload();
|
||||
})
|
||||
.fail(function() { bootbox.alert("Server request failed!"); });
|
||||
}
|
||||
});
|
||||
|
||||
$("#persona-signin").click(function() {
|
||||
navigator.id.request();
|
||||
});
|
||||
|
||||
$("#persona-signout").click(function() {
|
||||
navigator.id.logout();
|
||||
});
|
||||
function doLogout() {
|
||||
$.post("[% c.uri_for('/logout') %]")
|
||||
.done(function(data) {
|
||||
window.location.reload();
|
||||
})
|
||||
.fail(function() { bootbox.alert("Server request failed!"); });
|
||||
}
|
||||
</script>
|
||||
|
||||
[% IF c.user_exists && c.user.password != '!' %]
|
||||
<script>
|
||||
$("#persona-signout").click(doLogout);
|
||||
</script>
|
||||
[% ELSE %]
|
||||
<script src="https://login.persona.org/include.js"></script>
|
||||
|
||||
<script>
|
||||
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!"); });
|
||||
},
|
||||
onlogout: doLogout
|
||||
});
|
||||
|
||||
$("#persona-signin").click(function() {
|
||||
navigator.id.request();
|
||||
});
|
||||
|
||||
$("#persona-signout").click(function() {
|
||||
navigator.id.logout();
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
@ -2,9 +2,8 @@
|
||||
[% PROCESS common.tt %]
|
||||
|
||||
[% IF c.user_exists %]
|
||||
<p class="btn-info btn-large">
|
||||
You are already logged in as <tt>[% c.user.username %]</tt>.
|
||||
You can <a href="[% c.uri_for('/logout') %]">logout</a> here.
|
||||
<p class="alert alert-info">
|
||||
You are already signed in as <tt>[% HTML.escape(c.user.username) %]</tt>.
|
||||
</p>
|
||||
[% ELSE %]
|
||||
|
||||
@ -13,7 +12,6 @@ You can <a href="[% c.uri_for('/logout') %]">logout</a> here.
|
||||
c.uri_for('/register') %]">register</a> first.</p>
|
||||
-->
|
||||
|
||||
<!--
|
||||
<form class="form-horizontal" method="post" action="[% c.uri_for('/login') %]">
|
||||
|
||||
<fieldset>
|
||||
@ -37,7 +35,6 @@ c.uri_for('/register') %]">register</a> first.</p>
|
||||
</fieldset>
|
||||
|
||||
</form>
|
||||
-->
|
||||
|
||||
[% END %]
|
||||
|
||||
|
Reference in New Issue
Block a user