blob: af6db53526221181904e3ba67b870bd541283d99 (
plain) (
tree)
|
|
<h1>authentication</h1>
<div id="authenticator">
<p>
<%= if @bot, do: "Send this to #{@bot} on #{@network}:", else: "Find your bot nickname and send:" %><br /><br />
<strong>/msg <%= @bot || "the-bot-nickname" %> web</strong>
<br /><br />
... then come back to this address.
</p>
</div>
<script type="text/javascript">
var authSse = new EventSource("/api/irc-auth.sse?redirect_to=" + window.location.pathname);
authSse.addEventListener("token", function(event) {
html = "<%= if @bot, do: "Send this to #{@bot} on #{@network}:", else: "Find your bot nickname and send:" %><br /><br /><strong>/msg <%= @bot || "the-bot-nickname" %> "+event.data+"</strong>";
elem = document.getElementById("authenticator");
elem.innerHTML = html;
});
authSse.addEventListener("authenticated", function(event) {
elem = document.getElementById("authenticator");
elem.innerHTML = "<strong>success, redirecting...</strong>";
window.keepInner = true;
window.location.pathname = event.data;
});
authSse.addEventListener("expire", function(event) {
elem = document.getElementById("authenticator");
elem.innerHTML = "<strong>authentication expired</strong>";
window.keepInner = true;
});
authSse.onerror = function() {
authSse.close();
if (!window.keepInner) {
elem = document.getElementById("authenticator");
elem.innerHTML = "<strong>server closed connection :(</strong>";
}
};
</script>
|