From 8299915502ef482f10526ef9b84cc228abbb1594 Mon Sep 17 00:00:00 2001 From: Arzumify Date: Mon, 29 Apr 2024 01:45:22 +0100 Subject: [PATCH] Added aeskeyshare and fixed html files to be more standard-complient --- main.go | 4 ++++ static/js/aeskeyshare.js | 24 ++++++++++++++++++++++++ templates/aeskeyshare.html | 11 +++++++++++ templates/dashboard.html | 3 ++- templates/login.html | 25 ++++++++----------------- templates/logout.html | 21 ++++++--------------- templates/main.html | 30 +++++++++++------------------- templates/signup.html | 25 ++++++++----------------- 8 files changed, 74 insertions(+), 69 deletions(-) create mode 100644 static/js/aeskeyshare.js create mode 100644 templates/aeskeyshare.html diff --git a/main.go b/main.go index d32e410..ce3ea50 100644 --- a/main.go +++ b/main.go @@ -275,6 +275,10 @@ func main() { c.HTML(200, "dashboard.html", gin.H{}) }) + router.GET("/aeskeyshare", func(c *gin.Context) { + c.HTML(200, "keyshare.html", gin.H{}) + }) + router.GET("/.well-known/openid-configuration", func(c *gin.Context) { c.HTML(200, "openid.html", gin.H{}) }) diff --git a/static/js/aeskeyshare.js b/static/js/aeskeyshare.js new file mode 100644 index 0000000..09d2d97 --- /dev/null +++ b/static/js/aeskeyshare.js @@ -0,0 +1,24 @@ +window.addEventListener("message", function(event) { + try { + let data = JSON.parse(event.data); + const access_token = data["access_token"]; + const redirect_uri = data["redirect_uri"]; + + fetch("https://auth.hectabit.org/api/isloggedin", { + method: "POST", + body: JSON.stringify({ + access_token: access_token + }) + }) + .then((response) => { + if (response.status === 200) { + console.log("Key is valid"); + let newtab = window.open(redirect_uri); + newtab.postMessage(localStorage.getItem("DONOTSHARE-password"), "*"); + window.close(); + } + }); + } catch { + console.log("Error parsing JSON"); + } +}); diff --git a/templates/aeskeyshare.html b/templates/aeskeyshare.html new file mode 100644 index 0000000..39ceda8 --- /dev/null +++ b/templates/aeskeyshare.html @@ -0,0 +1,11 @@ + + + + + Burgerauth + + + + +

Redirecting...

+ diff --git a/templates/dashboard.html b/templates/dashboard.html index 87aabfe..0963d5c 100644 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -1,8 +1,9 @@ - + + Dashboard
diff --git a/templates/login.html b/templates/login.html index 17ed7ab..a369b47 100644 --- a/templates/login.html +++ b/templates/login.html @@ -1,28 +1,19 @@ - + - Login - Hectabit + Login - Burgerauth - - - - + + +

Image by perga (@pergagreen on discord)

- +

Login

@@ -33,8 +24,8 @@

-

Don't have an account? If so, Create one here!

- Privacy & Terms +

Don't have an account? If so, Create one here!

+ Privacy & Terms
diff --git a/templates/logout.html b/templates/logout.html index 821930e..aa59d17 100644 --- a/templates/logout.html +++ b/templates/logout.html @@ -1,25 +1,16 @@ - + - Burgernotes + Burgerauth - - - -Logging out.. + + +

Logging out...

diff --git a/templates/main.html b/templates/main.html index cc2a7c9..05af2e1 100644 --- a/templates/main.html +++ b/templates/main.html @@ -1,22 +1,14 @@ - + Authorize application - - - + + + - - + + +

Image by perga (@pergagreen on discord)

- +

Signup

Signup for an account

@@ -30,9 +21,9 @@


-

Already have an account? If so, Login instead!

+

Already have an account? If so, Login instead!

Please note that it's impossible to reset your password, do not forget it!

- Privacy & Terms + Privacy & Terms