user fixes

This commit is contained in:
zramsay 2025-03-11 17:53:06 -04:00
parent 368c633eb9
commit 7a7c42079d
3 changed files with 13 additions and 6 deletions

View File

@ -191,10 +191,14 @@ export async function POST(req: NextRequest): Promise<NextResponse> {
// Award points to the user for uploading a valid animal image
// We've already extracted user info in the authentication section above
if (userId && userEmail) {
console.log('Awarding points to user:', { userId, userEmail });
// Use email as ID if needed - this allows points to be accumulated
// even if the user ID is not available from the session
const pointsUserId = userId || userEmail;
if (pointsUserId && userEmail) {
console.log('Awarding points to user:', { pointsUserId, userEmail });
await awardPointsForImage(
userId,
pointsUserId,
userEmail,
buffer,
ipfsUrl,
@ -203,7 +207,7 @@ export async function POST(req: NextRequest): Promise<NextResponse> {
).catch(err => console.error('Failed to award points for image:', err));
} else {
console.log('Unable to award points, missing user data', {
userId,
pointsUserId,
userEmail
});
}

View File

@ -43,10 +43,13 @@ const Page: React.FC = (): React.ReactElement => {
// Prepare session data for API call
let sessionData;
if (isAuthenticated && session && session.user) {
// Use email as a fallback ID if id is undefined
sessionData = {
userId: session.user.id,
userId: session.user.id || session.user.email || '',
userEmail: session.user.email || ''
};
console.log('Session data being sent to API:', sessionData);
}
// Analyze the normalized image with session data

2
src/types/auth.d.ts vendored
View File

@ -3,7 +3,7 @@ import "next-auth";
declare module "next-auth" {
interface Session {
user: {
id: string;
id?: string;
name?: string | null;
email?: string | null;
image?: string | null;