Updated profile and post capabilities

This commit is contained in:
Sven laptop
2026-07-29 22:35:36 +02:00
parent eaeb0a29bc
commit 494b583cbc
9 changed files with 485 additions and 34 deletions
+27
View File
@@ -0,0 +1,27 @@
const express = require('express');
const router = express.Router();
const pool = require('../../db');
const { strictInput } = require('../../middleware/strict_input');
const { authenticateToken } = require('../../middleware/authenticate_token');
async function verifyAuth(req, res) {
try {
const { rows } = await pool.query(
'SELECT id, name, username, email FROM people WHERE id = $1',
[req.user.id]
);
if (rows.length === 0) {
return res.status(404).send('User not found');
}
return res.status(200).json(rows[0]);
} catch (err) {
console.error('verify auth failed', { message: err.message, code: err.code });
return res.status(500).send('Session verification failed, request could not be completed');
}
}
router.get('/', authenticateToken, strictInput(), verifyAuth);
router.get('/me', authenticateToken, strictInput(), verifyAuth);
router.get('/verify', authenticateToken, strictInput(), verifyAuth);
module.exports = router;