Initial commit: Expedição Gold SaaS

This commit is contained in:
Carlos
2026-06-25 00:55:34 +02:00
commit 1bf21f0754
13 changed files with 1356 additions and 0 deletions
+31
View File
@@ -0,0 +1,31 @@
import { compareSync } from 'bcryptjs';
// In-memory store (same as signup)
let users = [];
export default function handler(req, res) {
if (req.method !== 'POST') {
return res.status(405).json({ message: 'Method not allowed' });
}
const { username, password } = req.body;
if (!username || !password) {
return res.status(400).json({ message: 'Username and password required' });
}
const user = users.find(u => u.username === username);
if (!user) {
return res.status(401).json({ message: 'Invalid credentials' });
}
const valid = compareSync(password, user.password);
if (!valid) {
return res.status(401).json({ message: 'Invalid credentials' });
}
// Fake JWT token
const token = `${user.id}:${Date.now()}`;
res.status(200).json({ token, user: { id: user.id, username: user.username } });
}