fixed a bit of css

This commit is contained in:
bobbert committed 2025-03-11 19:01:49 +00:00
1 parent 623e5d60bf
commit 795d43e1a5
4 files changed
+534 -751

No files matched your search

+11 -8
View File
@@ -7,8 +7,16 @@ export async function POST(request) {
try {
const session = await getServerSession(authOptions);
// Debugging: Log the session
console.log('Session:', session);
if (!session) {
return Response.json({ success: false, error: 'Unauthorised-tc' }, { status: 401 });
return Response.json({ success: false, error: 'Unauthorised' }, { status: 401 });
}
// Ensure the user is not an admin
if (session.user.role === 'admin') {
return Response.json({ success: false, error: 'Admins cannot create teams' }, { status: 403 });
}
const { name, userId } = await request.json();
@@ -17,18 +25,13 @@ export async function POST(request) {
return Response.json({ success: false, error: 'Team name is required' });
}
// Verify the requesting user matches the userId
if (session.user.id !== userId) {
return Response.json({ success: false, error: 'User ID mismatch' }, { status: 403 });
}
// Generate a unique team code (6 characters)
const teamCode = nanoid(6).toUpperCase();
// Insert the new team
const result = await run(
'INSERT INTO teams (name, code, created_by) VALUES (?, ?, ?)',
[name, teamCode, userId]
'INSERT INTO teams (name, code) VALUES (?, ?)',
[name, teamCode]
);
if (!result || !result.lastID) {