You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
869 B
26 lines
869 B
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
|
import type { NextApiRequest, NextApiResponse } from 'next';
|
|
import Pool from "../../server/db/connect";
|
|
const pool = Pool;
|
|
|
|
type Data = {
|
|
name: string
|
|
}
|
|
|
|
export default function handler(
|
|
req: NextApiRequest,
|
|
res: NextApiResponse<Data>
|
|
) {
|
|
const _data = req.body._data;
|
|
if (req.method === 'POST') {
|
|
pool.query("SELECT salt FROM user WHERE login=?", [_data.name], function(err, rows) {
|
|
if (rows.length<1) {
|
|
res.status(200).json({error:'Неверный логин'});
|
|
console.log({error:'Неверный логин'});
|
|
} else {
|
|
res.status(200).json({error:'Неверный пароль'});
|
|
console.log({error:'Неверный пароль'});
|
|
}
|
|
})
|
|
}
|
|
}
|
|
|