fix(auth): remove synthetic-admin bypass (Brief 2 of fix-auth-bypass) #8
2 changed files with 2 additions and 16 deletions
|
|
@ -10,9 +10,7 @@ export async function getUserFromRequest(req) {
|
|||
const authHeader = req.headers.authorization;
|
||||
|
||||
if (!authHeader || !authHeader.startsWith('Bearer ')) {
|
||||
// For development, return user ID 1 if no token (should be removed in production)
|
||||
console.warn('⚠️ Development mode: Using fallback user authentication');
|
||||
return { userId: 1, email: 'admin@tcgvault.com', role: 'admin' };
|
||||
return null;
|
||||
}
|
||||
|
||||
const token = authHeader.substring(7);
|
||||
|
|
|
|||
|
|
@ -22,19 +22,7 @@ export default async function handler(req, res) {
|
|||
const authHeader = req.headers.authorization;
|
||||
|
||||
if (!authHeader || !authHeader.startsWith('Bearer ')) {
|
||||
// For development, return admin user if no token provided
|
||||
// In production, this should return 401
|
||||
const result = await sql`
|
||||
SELECT id, email, role, created_at
|
||||
FROM users
|
||||
WHERE email = 'admin@tcgvault.com'
|
||||
`;
|
||||
|
||||
if (result.rows.length > 0) {
|
||||
return res.status(200).json(result.rows[0]);
|
||||
} else {
|
||||
return res.status(401).json({ error: 'No admin user found' });
|
||||
}
|
||||
return res.status(401).json({ error: 'Authentication required' });
|
||||
}
|
||||
|
||||
const token = authHeader.substring(7);
|
||||
|
|
|
|||
Loading…
Reference in a new issue