summaryrefslogtreecommitdiff
path: root/lib/lsg_web/templates/alcoolog/auth.html.eex
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--lib/lsg_web/templates/alcoolog/auth.html.eex39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/lsg_web/templates/alcoolog/auth.html.eex b/lib/lsg_web/templates/alcoolog/auth.html.eex
new file mode 100644
index 0000000..af6db53
--- /dev/null
+++ b/lib/lsg_web/templates/alcoolog/auth.html.eex
@@ -0,0 +1,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>
+