From ecf89dba19f335e606f409d87b2d95e46f966038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Tue, 20 May 2025 19:08:21 +0300 Subject: [PATCH] add login, signup, settings, delete confirm markup --- apps/users.lua | 32 ++++++++++------------- sass/style.scss | 34 ++++++++++++++++++++++++- static/style.css | 33 +++++++++++++++++++++++- views/common/topnav.etlua | 7 ++--- views/user/delete_confirm.etlua | 23 +++++++++-------- views/user/login.etlua | 26 ++++++++++--------- views/user/settings.etlua | 45 ++++++++++++++++++--------------- views/user/signup.etlua | 32 ++++++++++++----------- 8 files changed, 152 insertions(+), 80 deletions(-) diff --git a/apps/users.lua b/apps/users.lua index 38a71a4..1d98165 100644 --- a/apps/users.lua +++ b/apps/users.lua @@ -106,31 +106,27 @@ app:get("user", "/:username", function(self) end) app:post("user_delete", "/:username/delete", function(self) + -- this route explicitly does not handle admins deleting other users + -- i might make a separate route for it later, but guesting users is possible local me = util.get_logged_in_user(self) if me == nil then self.session.flash = {error = "You must be logged in to perform this action."} return {redirect_to = self:url_for("user_login")} end local target_user = Users:find({username = self.params.username}) - if not me:is_mod() then - if me.id ~= target_user.id then - return {redirect_to = self:url_for("user", {username = self.params.username})} - end - - if not authenticate_user(target_user, self.params.password) then - self.session.flash = {error = "The password you entered is incorrect."} - return {redirect_to = self:url_for("user_delete_confirm", {username = me.username})} - end - - util.transfer_and_delete_user(target_user) - self.session.flash = {error = "Your account has been added to the deletion queue."} - return {redirect_to = self:url_for("user_signup")} - else - if target_user.permission >= me.permission then - self.session.flash = {error = "You can not delete another moderator."} - return {redirect_to = self:url_for("user", {username = me.username})} - end + + if me.id ~= target_user.id then + return {redirect_to = self:url_for("user", {username = self.params.username})} end + + if not authenticate_user(target_user, self.params.password) then + self.session.flash = {error = "The password you entered is incorrect."} + return {redirect_to = self:url_for("user_delete_confirm", {username = me.username})} + end + + util.transfer_and_delete_user(target_user) + self.session.flash = {error = "Your account has been added to the deletion queue."} + return {redirect_to = self:url_for("user_signup")} end) app:get("user_delete_confirm", "/:username/delete_confirm", function(self) diff --git a/sass/style.scss b/sass/style.scss index 81c05a1..7c3cbd6 100644 --- a/sass/style.scss +++ b/sass/style.scss @@ -8,6 +8,7 @@ $dark_bg: color.scale($accent_color, $lightness: -25%, $saturation: -97%); $dark2: color.scale($accent_color, $lightness: -30%, $saturation: -60%); $light: color.scale($accent_color, $lightness: 40%, $saturation: -60%); +$lighter: color.scale($accent_color, $lightness: 60%, $saturation: -60%); $main_bg: color.scale($accent_color, $lightness: -10%, $saturation: -40%); $button_color: color.adjust($accent_color, $hue: 90); @@ -66,6 +67,7 @@ body { .darkbg { padding-bottom: 10px; padding-left: 10px; + padding-right: 10px; background-color: $dark_bg; } @@ -75,8 +77,11 @@ body { } .site-title { - display: inline; padding-right: 30px; + font-size: 1.5rem; + font-weight: bold; + text-decoration: none; + color: black; } .thread-title { @@ -197,6 +202,7 @@ button, input[type="submit"], .linkbutton { // not sure why this one has to be separate, but if it's included in the rule above everything breaks input[type="file"]::file-selector-button { @include button($button_color); + margin: 10px 10px; } .pagebutton { @@ -221,3 +227,29 @@ input[type="file"]::file-selector-button { .modform { display: inline; } + +.login-container > * { + width: 25%; + margin: auto; +} + +.settings-container > * { + width: 40%; + margin: auto; +} + +.avatar-form { + display: flex; + flex-direction: column; + align-items: center; + padding: 20px 0; +} + +input[type="text"], input[type="password"] { + border: 1px solid black; + border-radius: 3px; + padding: 7px 10px; + width: 100%; + box-sizing: border-box; + background-color: $lighter; +} diff --git a/static/style.css b/static/style.css index cfdf48e..d47f189 100644 --- a/static/style.css +++ b/static/style.css @@ -39,6 +39,7 @@ body { .darkbg { padding-bottom: 10px; padding-left: 10px; + padding-right: 10px; background-color: rgb(143.7039271654, 144.3879625984, 142.8620374016); } @@ -48,8 +49,11 @@ body { } .site-title { - display: inline; padding-right: 30px; + font-size: 1.5rem; + font-weight: bold; + text-decoration: none; + color: black; } .thread-title { @@ -179,6 +183,7 @@ button.warn:active, input[type=submit].warn:active, .linkbutton.warn:active { input[type=file]::file-selector-button { background-color: rgb(177, 206, 204.5); + margin: 10px 10px; } input[type=file]::file-selector-button:hover { background-color: rgb(192.6, 215.8, 214.6); @@ -214,3 +219,29 @@ input[type=file]::file-selector-button:active { .modform { display: inline; } + +.login-container > * { + width: 25%; + margin: auto; +} + +.settings-container > * { + width: 40%; + margin: auto; +} + +.avatar-form { + display: flex; + flex-direction: column; + align-items: center; + padding: 20px 0; +} + +input[type=text], input[type=password] { + border: 1px solid black; + border-radius: 3px; + padding: 7px 10px; + width: 100%; + box-sizing: border-box; + background-color: rgb(229.84, 231.92, 227.28); +} diff --git a/views/common/topnav.etlua b/views/common/topnav.etlua index 4aa4fba..f50ed1d 100644 --- a/views/common/topnav.etlua +++ b/views/common/topnav.etlua @@ -1,10 +1,11 @@