From 3eddd0ea5bf1f4bd7d9b5c3dbf2b156740dba9af Mon Sep 17 00:00:00 2001 From: rainbow napkin Date: Sat, 28 Dec 2024 15:55:03 -0500 Subject: [PATCH] Tidied up login page/navbar. --- src/controllers/loginController.js | 6 ++++++ src/views/login.ejs | 3 +++ src/views/partial/navbar.ejs | 2 +- www/css/login.css | 6 +++++- www/js/navbar.js | 6 ++++++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/controllers/loginController.js b/src/controllers/loginController.js index 8e36b30..565542f 100644 --- a/src/controllers/loginController.js +++ b/src/controllers/loginController.js @@ -29,6 +29,12 @@ module.exports.get = async function(req, res){ //Check for validation errors const validResult = validationResult(req); + //If this request is coming from someone who's already logged in + if(req.session.user != null){ + //Redirect them to the homepage + return res.redirect('/'); + } + //If there are none if(validResult.isEmpty()){ //Get username from sanatized/validated data diff --git a/src/views/login.ejs b/src/views/login.ejs index 69c08e8..d6fa715 100644 --- a/src/views/login.ejs +++ b/src/views/login.ejs @@ -24,6 +24,7 @@ along with this program. If not, see .--> <%- include('partial/navbar', {user}); %> +

User Login

<% if(challenge != null){ %>

Multiple failed attempts detected!

Please complete verification challenge to continue!

@@ -36,6 +37,8 @@ along with this program. If not, see .--> <% if(challenge != null){ %> <% } %> + Create New Account + Forgot Password diff --git a/src/views/partial/navbar.ejs b/src/views/partial/navbar.ejs index e1369f5..cdd4f19 100644 --- a/src/views/partial/navbar.ejs +++ b/src/views/partial/navbar.ejs @@ -21,7 +21,7 @@ along with this program. If not, see .--> <% }else{ %> - + <% } %> \ No newline at end of file diff --git a/www/css/login.css b/www/css/login.css index c2dc9e1..ede0b1a 100644 --- a/www/css/login.css +++ b/www/css/login.css @@ -13,12 +13,16 @@ GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see .*/ +h2{ + text-align: center; +} + form{ display: flex; flex-direction: column; align-items: center; gap: 0.5em; - margin: 5% 17%; + margin: 0 17%; } .login-page-prompt{ diff --git a/www/js/navbar.js b/www/js/navbar.js index 87cd62a..416f13b 100644 --- a/www/js/navbar.js +++ b/www/js/navbar.js @@ -20,6 +20,12 @@ async function navbarLogin(event){ var user = document.querySelector("#username-prompt").value; var pass = document.querySelector("#password-prompt").value; + //If no user or pass is presented + if(user == "" || pass == ""){ + //Go to login page + window.location = '/login' + } + utils.ajax.login(user, pass); } }