First commit of the new Insider version on docker

This commit is contained in:
2024-03-27 18:20:08 +01:00
parent 7637b068f9
commit be57c29e6e
61 changed files with 13693 additions and 1 deletions

47
models/UserManagment.js Normal file
View File

@@ -0,0 +1,47 @@
const mysql = require('mysql2/promise');
const pool = require('../config/database');
const userSchema = {
username: {
type: 'VARCHAR(255)',
allowNull: false,
unique: true
},
password: {
type: 'VARCHAR(255)',
allowNull: false
},
isAdmin: {
type: 'BOOLEAN',
allowNull: false,
defaultValue: false
}
};
async function createUser(username, password, isAdmin) {
const connection = await pool.getConnection();
try {
const [rows] = await connection.execute(
'INSERT INTO cdn (username, password, isAdmin) VALUES (?, ?, ?)',
[username, password, isAdmin]
);
return rows.insertId;
} finally {
connection.release();
}
}
async function getUserByUsername(username) {
const connection = await pool.getConnection();
try {
const [rows] = await connection.execute('SELECT * FROM users WHERE username = ?', [username]);
return rows[0];
} finally {
connection.release();
}
}
module.exports = {
createUser,
getUserByUsername
};