Tidied up login page/navbar.

This commit is contained in:
rainbow napkin 2024-12-28 15:55:03 -05:00
parent 478edeeddf
commit 3eddd0ea5b
5 changed files with 21 additions and 2 deletions

View file

@ -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

View file

@ -24,6 +24,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.-->
</head>
<body>
<%- include('partial/navbar', {user}); %>
<h2>User Login</h2>
<% if(challenge != null){ %>
<h3 class="danger-text">Multiple failed attempts detected!</h3>
<p class="danger-text">Please complete verification challenge to continue!</p>
@ -36,6 +37,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.-->
<% if(challenge != null){ %>
<altcha-widget challengejson="<%= JSON.stringify(challenge) %>"></altcha-widget>
<% } %>
<a href="/register">Create New Account</a>
<a href="/passwordReset">Forgot Password</a>
<button id="login-page-button" class='positive-button'>Login</button>
</form>
</body>

View file

@ -21,7 +21,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.-->
<% }else{ %>
<input class="navbar-item login-prompt" id="username-prompt" placeholder="username">
<input class="navbar-item login-prompt" id="password-prompt" placeholder="password" type="password">
<p class="navbar-item"><a class="navbar-item" href="javascript:" id="login-button">Login</a> - <a class="navbar-item" href="/register">Register</a></p>
<p class="navbar-item"><a class="navbar-item" href="javascript:" id="login-button">Login</a> - <a class="navbar-item" href="/passwordReset">Forgot Password</a> - <a class="navbar-item" href="/register">Register</a></p>
<% } %>
</span>
</div>

View file

@ -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 <https://www.gnu.org/licenses/>.*/
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{

View file

@ -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);
}
}