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

+30
View File
@@ -0,0 +1,30 @@
import NextAuth from 'next-auth';
import Providers from 'next-auth/providers';
export const authOptions = {
providers: [
Providers.GitHub({
clientId: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET,
}),
// Add other providers here (e.g., Google, Email, etc.)
],
secret: process.env.NEXTAUTH_SECRET, // Ensure this is set in your .env file
callbacks: {
async session(session, user) {
// Add custom session properties if needed
session.user.id = user.id;
session.user.role = user.role; // Example: Add role to session
return session;
},
async jwt(token, user) {
if (user) {
token.id = user.id;
token.role = user.role; // Example: Add role to token
}
return token;
},
},
};
export default NextAuth(authOptions);
+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) {