widget email 8

This commit is contained in:
Alma 2025-04-13 21:13:00 +02:00
parent 57bc16072f
commit 6ecdda9b82
2 changed files with 13 additions and 4 deletions

View File

@ -59,6 +59,10 @@ export const authOptions: NextAuthOptions = {
},
}),
],
session: {
strategy: "jwt",
maxAge: 30 * 24 * 60 * 60, // 30 days
},
callbacks: {
async jwt({ token, account, profile }) {
// Log only non-sensitive information
@ -128,7 +132,6 @@ export const authOptions: NextAuthOptions = {
};
}
},
async session({ session, token }) {
console.log("Session callback - processing session for user:", token.sub);
@ -153,7 +156,7 @@ export const authOptions: NextAuthOptions = {
session.rocketChatUserId = token.rocketChatUserId || null;
return session;
},
}
},
events: {
async signOut({ token }) {
@ -180,7 +183,11 @@ export const authOptions: NextAuthOptions = {
}
},
},
debug: process.env.NODE_ENV === 'development', // Only enable debug logging in development
pages: {
signIn: '/signin',
error: '/signin',
},
debug: process.env.NODE_ENV === 'development',
};
const handler = NextAuth(authOptions);

View File

@ -23,7 +23,7 @@ export async function GET(req: NextRequest) {
}
// First, get a Nextcloud OIDC token using client credentials
const tokenResponse = await fetch(`${nextcloudUrl}/index.php/apps/oauth2/api/v1/token`, {
const tokenResponse = await fetch(`${nextcloudUrl}/apps/oauth2/api/v1/token`, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
@ -36,9 +36,11 @@ export async function GET(req: NextRequest) {
});
if (!tokenResponse.ok) {
const errorData = await tokenResponse.json();
console.error('Failed to get Nextcloud token:', {
status: tokenResponse.status,
statusText: tokenResponse.statusText,
error: errorData
});
return NextResponse.json({ error: 'Nextcloud authentication failed' }, { status: 401 });
}