Poprawki i hash hasła

main
kry008 2025-01-08 08:46:26 +01:00
parent 6201f48a73
commit 47ce6c3229
3 changed files with 8 additions and 7 deletions

View File

@ -19,7 +19,7 @@ con.connect(function(err) {
}); });
var bodyParser = require('body-parser'); var bodyParser = require('body-parser');
apiLiczacy.use(bodyParser.json()); apiLiczacy.use(bodyParser.json());
const {loger, sendToDiscord, sendEmail, makeid, checkSendEmail, baza} = require('./func.js'); const {loger, sendToDiscord, sendEmail} = require('./func.js');
apiLiczacy.use(function(req, res, next) { apiLiczacy.use(function(req, res, next) {
var token = req.headers.token || req.body.token; var token = req.headers.token || req.body.token;

View File

@ -25,7 +25,9 @@ api.use(bodyParser.json());
api.post("/loginPanel", function(req, res) { api.post("/loginPanel", function(req, res) {
var login = req.body.login; var login = req.body.login;
var password = req.body.password; var password = req.body.password;
con.query("SELECT * FROM login WHERE login = ? AND haslo = ?", [login, password], function(err, result) { console.log(req.body);
con.query("SELECT * FROM login WHERE login = ? AND haslo = SHA1(?)", [login, password], function(err, result) {
//jeżeli znajdziesz wygeneruj token i zapamiętaj go w bazie //jeżeli znajdziesz wygeneruj token i zapamiętaj go w bazie
if (result.length > 0) { if (result.length > 0) {
var token = makeid(64); var token = makeid(64);

View File

@ -66,6 +66,10 @@ function tryConnect() {
const liczacy = require('./liczacy.js'); const liczacy = require('./liczacy.js');
const apiRoutes = require('./apiRoutes.js'); const apiRoutes = require('./apiRoutes.js');
app.use('/panel', panelRoutes);
app.use('/liczacy', liczacy);
app.use('/api', apiRoutes);
app.get('/', function(req, res) { app.get('/', function(req, res) {
res.redirect('/panel'); res.redirect('/panel');
}); });
@ -184,11 +188,6 @@ function tryConnect() {
res.redirect('/panel/home'); res.redirect('/panel/home');
}); });
app.use('/panel', panelRoutes);
app.use('/liczacy', liczacy);
app.use('/api', apiRoutes);
app.all('/statystyki2', function(req, res) { app.all('/statystyki2', function(req, res) {
var toReturn = headerHtml("Statystyki"); var toReturn = headerHtml("Statystyki");
toReturn += menuHtml(0); toReturn += menuHtml(0);