From 3271fab6d848f4c1c0b0f3b518a2cf9b293df609 Mon Sep 17 00:00:00 2001 From: stringsplit <77242831+nbitzz@users.noreply.github.com> Date: Tue, 28 Feb 2023 20:07:40 -0800 Subject: [PATCH] this isn't spaghetti code this is an abomination --- src/server/routes/authRoutes.ts | 2 +- src/style/app/pulldown.scss | 6 +- src/style/app/pulldown/accounts.scss | 74 --------------- src/style/app/pulldown/modals.scss | 99 +++++++++++++++++++++ src/svelte/elem/prompts/OptionPicker.svelte | 77 ++++++++++++++++ src/svelte/elem/prompts/passwordChange.js | 31 +++++++ src/svelte/elem/pulldowns/Accounts.svelte | 9 +- 7 files changed, 218 insertions(+), 80 deletions(-) create mode 100644 src/style/app/pulldown/modals.scss create mode 100644 src/svelte/elem/prompts/OptionPicker.svelte create mode 100644 src/svelte/elem/prompts/passwordChange.js diff --git a/src/server/routes/authRoutes.ts b/src/server/routes/authRoutes.ts index 32bd072..ba7a383 100644 --- a/src/server/routes/authRoutes.ts +++ b/src/server/routes/authRoutes.ts @@ -138,7 +138,7 @@ authRoutes.post("/change_password", (req,res) => { return } - if (body.password.length < 8) { + if (typeof body.password != "string" || body.password.length < 8) { ServeError(res,400,"password must be 8 characters or longer") return } diff --git a/src/style/app/pulldown.scss b/src/style/app/pulldown.scss index 7765f29..9d37ecc 100644 --- a/src/style/app/pulldown.scss +++ b/src/style/app/pulldown.scss @@ -2,17 +2,17 @@ @use "pulldown/help"; @use "pulldown/accounts"; @use "pulldown/files"; +@use "pulldown/modals"; -#overlay { +#overlay, .modalContainer { position:absolute; left:0px; height: 100%; width:100%; top:0px; - opacity:0.25; border:none; outline:none; - background-color:#AAAAAA; + background-color:rgba(170, 170, 170, 0.25); z-index: 1000; } diff --git a/src/style/app/pulldown/accounts.scss b/src/style/app/pulldown/accounts.scss index 2a3b806..3cab4ef 100644 --- a/src/style/app/pulldown/accounts.scss +++ b/src/style/app/pulldown/accounts.scss @@ -161,79 +161,5 @@ } } } - - .accountOptions { - - button { - position:relative; - width:100%; - cursor:pointer; - height:50px; - background-color: #191919; - border:none; - border-bottom:1px solid #AAAAAA; - transition-duration:150ms; - - img { - position:absolute; - left:13px; - top:50%; - transform:translateY(-50%); - } - - p { - text-align:left; - position:absolute; - top:50%; - left:50px; - color:#DDDDDD; - transform:translateY(-50%); - font-size:14px; - - span { - color:#777777; - font-size:12px; - } - } - - &:hover { - transition-duration:150ms; - background-color: #252525; - } - - @media screen and (max-width:500px) { - height:70px; - p { - font-size:16px; - left:70px; - - span { - font-size:14px; - } - } - - img { - width:30px; - height:30px; - left:20px; - } - } - - } - - .category { - border-bottom: 1px solid #AAAAAA; - - p { - color: #AAAAAA; - font-size: 14px; - margin: 10px 0px 3px 0px; - - @media screen and (max-width:500px) { - font-size:16px; - } - } - } - } } } \ No newline at end of file diff --git a/src/style/app/pulldown/modals.scss b/src/style/app/pulldown/modals.scss new file mode 100644 index 0000000..1cd413f --- /dev/null +++ b/src/style/app/pulldown/modals.scss @@ -0,0 +1,99 @@ +.optPicker { + + button, .inp { + position:relative; + width:100%; + height:50px; + background-color: #191919; + border:none; + border-bottom:1px solid #AAAAAA; + transition-duration:150ms; + + img { + position:absolute; + left:13px; + top:50%; + transform:translateY(-50%); + } + + p,input { + text-align:left; + position:absolute; + top:50%; + left:50px; + color:#DDDDDD; + transform:translateY(-50%); + font-size:14px; + background-color:#00000000; + border:none; + + span { + color:#777777; + font-size:12px; + } + } + + input { + height:100%; + width:calc(100% - 50px); + outline:none; /* bad idea but i don't even care anymore */ + margin:0px; + padding:0px; + } + + @media screen and (max-width:500px) { + height:70px; + p,input { + font-size:16px; + left:70px; + + span { + font-size:14px; + } + } + + input { + width:calc( 100% - 70px ); + } + + img { + width:30px; + height:30px; + left:20px; + } + } + + } + + button { + cursor:pointer; + + &:hover { + transition-duration:150ms; + background-color: #252525; + } + } + + .category { + border-bottom: 1px solid #AAAAAA; + + p { + color: #AAAAAA; + font-size: 14px; + margin: 10px 0px 3px 0px; + + @media screen and (max-width:500px) { + font-size:16px; + } + } + } +} + +.modal { + position:absolute; + background-color:#191919; + width:100%; + transform:translateY(-100%); + top:100%; + left:0%; +} diff --git a/src/svelte/elem/prompts/OptionPicker.svelte b/src/svelte/elem/prompts/OptionPicker.svelte new file mode 100644 index 0000000..2cda130 --- /dev/null +++ b/src/svelte/elem/prompts/OptionPicker.svelte @@ -0,0 +1,77 @@ + + +{#if activeModal} + + {/if} + {/each} + + + + + + +{/if} \ No newline at end of file diff --git a/src/svelte/elem/prompts/passwordChange.js b/src/svelte/elem/prompts/passwordChange.js new file mode 100644 index 0000000..6a39c78 --- /dev/null +++ b/src/svelte/elem/prompts/passwordChange.js @@ -0,0 +1,31 @@ +export function pwdChng(optPicker) { + optPicker.picker("Change password",[ + { + name: "New password", + icon: "/static/assets/icons/change_password.svg", + id: "password", + inputSettings: { + password: true + } + }, + { + name: "OK", + icon: "/static/assets/icons/update.svg", + description: "This will log you out of all sessions", + id: true + } + ]).then((exp) => { + if (exp && exp.selected) { + fetch(`/auth/change_password`,{method:"POST", body:JSON.stringify({ + password:exp.password + })}).then((response) => { + + if (response.status != 200) { + optPicker.picker(`${response.status} ${response.statusText}`,[]) + } + + fetchAccountData() + }) + } + }) +} \ No newline at end of file diff --git a/src/svelte/elem/pulldowns/Accounts.svelte b/src/svelte/elem/pulldowns/Accounts.svelte index 38cd587..65b190b 100644 --- a/src/svelte/elem/pulldowns/Accounts.svelte +++ b/src/svelte/elem/pulldowns/Accounts.svelte @@ -4,6 +4,8 @@ import { circIn,circOut } from "svelte/easing" import { account, fetchAccountData, serverStats } from "../stores.mjs"; import { fade } from "svelte/transition"; + import OptionPicker from "../prompts/OptionPicker.svelte"; + import { pwdChng } from "../prompts/passwordChange"; let targetAction let inProgress @@ -11,6 +13,8 @@ let pwErr + let optPicker; + // lazy let username @@ -59,6 +63,7 @@ + {#if Object.keys($account).length == 0}
@@ -108,7 +113,7 @@ Hey there, @{$account.username} -
+

Account

@@ -119,7 +124,7 @@

Change username

-