blob: af6db53526221181904e3ba67b870bd541283d99 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
<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>
|