mirror of
https://github.com/mito-systems/ranger-app.git
synced 2026-03-18 04:44:09 +00:00
user fixes
This commit is contained in:
parent
368c633eb9
commit
7a7c42079d
@ -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
|
||||
});
|
||||
}
|
||||
|
||||
@ -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
2
src/types/auth.d.ts
vendored
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user