From bc253efb50b3af042637b172ebc5a3b485c886ee Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Sat, 2 Jul 2022 22:59:02 +1000 Subject: [PATCH] Slowcord custom register page --- slowcord/public/css/index.css | 106 ++++++++++++++++++++++++++++++++++ slowcord/public/login.html | 101 +++----------------------------- slowcord/public/register.html | 86 +++++++++++++++++++++++++++ slowcord/src/index.ts | 13 +---- 4 files changed, 202 insertions(+), 104 deletions(-) create mode 100644 slowcord/public/css/index.css create mode 100644 slowcord/public/register.html diff --git a/slowcord/public/css/index.css b/slowcord/public/css/index.css new file mode 100644 index 00000000..1fa76966 --- /dev/null +++ b/slowcord/public/css/index.css @@ -0,0 +1,106 @@ +/* Can you tell I like flexbox? */ + +html { + --background-primary: rgb(22, 23, 25); + --background-secondary: rgb(15, 16, 18); + --foreground-primary: rgb(200, 200, 200); + --background-login-discord: #5865F2; + + background: url("https://slowcord.maddy.k.vu/assets/background.png"); + background-size: 100% 100%; + background-repeat: no-repeat; + + font-family: 'Montserrat', sans-serif; + + color: var(--foreground-primary); +} + +* { + margin: 0; + padding: 0; +} + +.content { + display: flex; + width: 100vw; + height: 100vh; + justify-content: flex-start; + align-items: center; +} + +.login { + height: 100%; + width: 25%; + min-width: 400px; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + + background-color: var(--background-primary); + + padding: 0 50px 0 50px; +} + +.header { + margin: 40px; + width: 100%; + text-align: center; + display: flex; + flex-direction: column; + justify-content: center; +} + +.header-subtext { + text-align: center; +} + +.header-subtext a, .header-subtext p { + display: inline-block; + margin: 0 10px 0 10px; +} + +a { + color: var(--foreground-primary); +} + +form { + display: flex; + flex-direction: column; + justify-content: center; + width: 100%; + min-height: 50%; +} + +input, +form a { + background-color: var(--background-secondary); + padding: 10px; + margin: 5px 0 5px 0; + outline: none; + border: 1px solid grey; + color: var(--foreground-primary); + text-decoration: none; + cursor: pointer; +} + +form a { + text-align: center; +} + +label { + text-transform: uppercase; + font-size: 0.75rem; + font-weight: bold; +} + +#loginDiscord { + background-color: var(--background-login-discord); +} + +#failure { + width: 100%; + margin-top: 10px; + color: rgb(200, 20, 20); + display: none; +} \ No newline at end of file diff --git a/slowcord/public/login.html b/slowcord/public/login.html index 586e7c61..ef2d91c1 100644 --- a/slowcord/public/login.html +++ b/slowcord/public/login.html @@ -10,93 +10,7 @@ - + @@ -104,7 +18,10 @@

Welcome to Slowcord

-

Glad to see you <3

+
+

Glad to see you <3

+ Wait, I'm new! +

Login failed

@@ -116,12 +33,10 @@ - + - Login with Discord @@ -139,7 +54,7 @@ if (token.trim().length) { /* https://stackoverflow.com/a/27374365 */ // why is clearing cookies so weird? wtf - document.cookie.split(";").forEach(function(c) { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); }); + document.cookie.split(";").forEach(function (c) { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); }); window.localStorage.setItem("token", `"${token}"`); window.location.href = "/app"; } diff --git a/slowcord/public/register.html b/slowcord/public/register.html new file mode 100644 index 00000000..d660394c --- /dev/null +++ b/slowcord/public/register.html @@ -0,0 +1,86 @@ + + + + + + + Slowcord + + + + + + + + + +
+ +
+ + + + + \ No newline at end of file diff --git a/slowcord/src/index.ts b/slowcord/src/index.ts index 20f0aee7..45fbea7d 100644 --- a/slowcord/src/index.ts +++ b/slowcord/src/index.ts @@ -79,7 +79,7 @@ const handlers: { [key: string]: any; } = { "discord": Discord, }; -app.use((req, res, next) => { +app.get("/oauth/:type", async (req, res) => { requestsThisSecond++; if (requestsThisSecond > allowedRequestsPerSecond) return res.sendStatus(429); @@ -98,10 +98,6 @@ app.use((req, res, next) => { delete rateLimits[ip]; } - next(); -}); - -app.get("/oauth/:type", async (req, res) => { const { type } = req.params; const handler = handlers[type]; if (!type || !handler) return res.sendStatus(400); @@ -128,12 +124,7 @@ app.get("/oauth/:type", async (req, res) => { res.sendFile(path.join(__dirname, "../public/login.html")); }); -// not actually needed but whatever -app.get("/app", (req, res) => res.sendStatus(200)); - -app.get("*", (req, res) => { - res.sendFile(path.join(__dirname, "../public/login.html")); -}); +app.use(express.static("public", { extensions: ["html"] })); (async () => { await initDatabase();