blob: 6e5cedc9b8f863330051b210d472ac7100c735c6 (
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
40
41
42
43
|
<div class="grid grid-cols-2">
<h1 class="text-2xl font-bold">authentication</h1>
<div class="text-right">
<%= link("connect using random.sh", to: "/login/oidc", class: "inline-block font-medium underline") %>
</div>
</div>
<div id="authenticator" class="mt-12 h-32 place-self-end justify-self-start">
<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 class='text-xl font-mono ml-12'>/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>
|