Added stuff to login page and fixed database connection

This commit is contained in:
Miles committed 2025-01-13 13:02:18 +00:00
1 parent f12244882e
commit adf240c68b
4 files changed
+21 -7

No files matched your search

+7 -5
View File
@@ -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;
+1 -1
View File
@@ -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);
+7
View File
@@ -2,6 +2,13 @@ document.addEventListener('DOMContentLoaded', () => {
$('#loginBtn').click(() => {
const username = $('#username').val();
const password = $('#password').val();
document.getElementById("loginBtn")
.innerHTML +=
`
<span id='loginSpinner' class="spinner-border spinner-border-sm" aria-hidden="true"></span>
`;
$.post('/auth/login', { username, password })
.done((data) => {
+6 -1
View File
@@ -8,7 +8,12 @@
<input class="form-control" type="password" id="password" name="password">
</div>
<button class="mt-2 btn btn-primary" id="loginBtn">Login</button>
<div id="loginBtnDiv">
<button class="btn btn-primary" id="loginBtn">
<span role="status">Login</span>
</button>
</div>
<p>Don't have an account? <a href="/auth/register">Register here</a>.</p>
</section>