27 lines
No EOL
606 B
JavaScript
27 lines
No EOL
606 B
JavaScript
import Route from "../route.js";
|
|
import initDb from "../db.js";
|
|
|
|
let db = await initDb();
|
|
|
|
let main = new Route([], async function (req, res, input) {
|
|
let body = { ...req.cookies, ...req.body };
|
|
|
|
let { token } = body;
|
|
|
|
let match = await db.all('SELECT * FROM token WHERE token = ?', [
|
|
token || 'blah'
|
|
]);
|
|
|
|
let username = match[0] ? match[0].username : '!nobody';
|
|
|
|
let valid = await db.all('SELECT * FROM auth WHERE username = ?', [
|
|
username
|
|
]);
|
|
|
|
return {
|
|
username,
|
|
valid: valid[0] ? valid[0].valid : 'noexist'
|
|
};
|
|
});
|
|
|
|
export default main; |