From adf240c68b5652ee8f5adb27b933b316e90f5367 Mon Sep 17 00:00:00 2001 From: Miles Date: Mon, 13 Jan 2025 13:02:18 +0000 Subject: [PATCH] Added stuff to login page and fixed database connection --- Models/User.js | 12 +++++++----- app.js | 2 +- public/javascripts/login.js | 7 +++++++ views/login.ejs | 7 ++++++- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Models/User.js b/Models/User.js index e9d4e28..ac5d74b 100644 --- a/Models/User.js +++ b/Models/User.js @@ -4,18 +4,20 @@ const sequelize = require('../db'); const User = sequelize.define('User', { username: { type: DataTypes.STRING, - allowNull: false, unique: true, + allowNull: false }, email: { type: DataTypes.STRING, - allowNull: false, unique: true, + allowNull: false }, password: { type: DataTypes.STRING, - allowNull: false, - }, + allowNull: false + } +}, { + timestamps: true }); -module.exports = User; +module.exports = User; \ No newline at end of file diff --git a/app.js b/app.js index 296bb05..4d92ab7 100644 --- a/app.js +++ b/app.js @@ -59,7 +59,7 @@ app.use('/inventory', ensureAuthenticated, require('./routes/inventory')); // Database Sync (async () => { try { - await sequelize.sync({ alter: true }); + await sequelize.sync({ alter: false }); console.log('Database synchronized.'); } catch (err) { console.error('Database sync error:', err); diff --git a/public/javascripts/login.js b/public/javascripts/login.js index d46a604..7f301b7 100644 --- a/public/javascripts/login.js +++ b/public/javascripts/login.js @@ -2,6 +2,13 @@ document.addEventListener('DOMContentLoaded', () => { $('#loginBtn').click(() => { const username = $('#username').val(); const password = $('#password').val(); + + document.getElementById("loginBtn") + .innerHTML += + ` + + `; + $.post('/auth/login', { username, password }) .done((data) => { diff --git a/views/login.ejs b/views/login.ejs index e6b03fa..4bf76bd 100644 --- a/views/login.ejs +++ b/views/login.ejs @@ -8,7 +8,12 @@ - +
+ +
+

Don't have an account? Register here.