I want my code only admin to be able to login. It should throw an error when other users enter.
const path = require('path');
const express = require('express');
const router = express.Router();
const baglanti=require('../util/vt_baglanti');
router.get('/login', (req,res,next) => {
baglanti.getConnection(function(err) {
if (err) throw err;
baglanti.query("SELECT * FROM sehir", function (err, result, fields) {
if (err) throw err;
res.render('login', {
sayfa_basligi:'Giriş',
path:'/admin/login',
sehir:result
});
});
});
})
router.post('/login', (req,res,next) => {
baglanti.getConnection(function(err) {
if (err) throw err;
console.log(req.body.kullaniciadi);
var sql = "SELECT * FROM kullanici WHERE kullaniciadi='"+req.body.kullaniciadi+"' AND
sifre='"+req.body.sifre+"'";
baglanti.query(sql, function (err, result) {
if (err) throw err;
});
});
res.redirect('/');
});
//module.exports=router;
exports.routes=router;