Fix authentication and Prisma query issues
This commit is contained in:
parent
15a95fb319
commit
6f4d758e5c
@ -8,7 +8,11 @@ export async function authenticate(
|
|||||||
formData: FormData,
|
formData: FormData,
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
await signIn('credentials', formData);
|
await signIn('credentials', {
|
||||||
|
email: formData.get('email'),
|
||||||
|
password: formData.get('password'),
|
||||||
|
redirectTo: '/',
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof AuthError) {
|
if (error instanceof AuthError) {
|
||||||
console.error('AuthError details:', error.type, error.message);
|
console.error('AuthError details:', error.type, error.message);
|
||||||
@ -20,10 +24,6 @@ export async function authenticate(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// IMPORTANT: Next.js redirects throw a special error that must be rethrown
|
// IMPORTANT: Next.js redirects throw a special error that must be rethrown
|
||||||
if (error instanceof Error && error.message === 'NEXT_REDIRECT') {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
console.error('Non-AuthError during signin:', error);
|
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,7 +25,7 @@ export async function getNotes(includeArchived = false) {
|
|||||||
const notes = await prisma.note.findMany({
|
const notes = await prisma.note.findMany({
|
||||||
where: {
|
where: {
|
||||||
userId: session.user.id,
|
userId: session.user.id,
|
||||||
isArchived: includeArchived ? {} : { isArchived: false },
|
...(includeArchived ? {} : { isArchived: false }),
|
||||||
},
|
},
|
||||||
orderBy: [
|
orderBy: [
|
||||||
{ isPinned: 'desc' },
|
{ isPinned: 'desc' },
|
||||||
|
|||||||
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user