Update userData to sql
This commit is contained in:
@@ -1,20 +1,15 @@
|
||||
import { type NextFunction, type Request, type Response } from "express";
|
||||
import UserModel from '../models/userModel';
|
||||
|
||||
import userModel, { values } from '../models/userModel';
|
||||
|
||||
async function checkAuthenticated(req: Request, res: Response, next: NextFunction) {
|
||||
try {
|
||||
const password = req.body.pass;
|
||||
const userFound = await UserModel.findOne({ pass: password });
|
||||
if (!userFound) {
|
||||
return res.status(404).json({ message: 'Wrong password' });
|
||||
const pass = req.body.pass;
|
||||
const password = await userModel.getValue(values.pass);
|
||||
if (pass && password) {
|
||||
if (pass == password) {
|
||||
return next();
|
||||
}
|
||||
req.user = userFound;
|
||||
return next();
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
return res.status(500).json({ message: 'Error when getting transactions.' });
|
||||
}
|
||||
return res.status(500).json({ message: 'Error when getting transactions.' });
|
||||
}
|
||||
|
||||
export default checkAuthenticated;
|
13
miscellaneous/custom.d.ts
vendored
13
miscellaneous/custom.d.ts
vendored
@@ -1,13 +0,0 @@
|
||||
|
||||
|
||||
declare namespace Express {
|
||||
export interface Request {
|
||||
user?: Document<unknown, {}, {
|
||||
pass?: string | undefined;
|
||||
omdb_key?: string | undefined;
|
||||
twitch_client_id?: string | undefined;
|
||||
twitch_client_secret?: string | undefined;
|
||||
mac_address?: string | undefined;
|
||||
}>
|
||||
}
|
||||
}
|
11
miscellaneous/db.ts
Normal file
11
miscellaneous/db.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import mysql from 'mysql2/promise'
|
||||
|
||||
const pool = mysql.createPool({
|
||||
host: '192.168.0.11',
|
||||
port: 3306,
|
||||
user: 'myUsage',
|
||||
password: 'vEj8lFj22srB_(VG',
|
||||
database: 'my_general_db'
|
||||
});
|
||||
|
||||
export default pool;
|
Reference in New Issue
Block a user