implementation of Auth.js with Next.js
Unanswered
miltone posted this in #help-forum
miltoneOP
I'm following the next.js tutorial about implementing Auth.js for my next.js app.
I'm writing my auth.ts file for controlling my users input.
But example use Credentials on 'next-auth/providers/credentials'
with this sample of code
this produce this error in my PHPStorm IDE like this :
I'm writing my auth.ts file for controlling my users input.
But example use Credentials on 'next-auth/providers/credentials'
with this sample of code
Credentials({
async authorize(credentials)
{
const parsedCredentials = z
.object({ email: z.string().email(), password: z.string().min(6) })
.safeParse(credentials);
if (parsedCredentials.success)
{
const { email, password } = parsedCredentials.data;
const user = await getUser(email);
if (!user) return null;
const passwordsMatch = await bcrypt.compare(password, user.password);
if (passwordsMatch) return user;
}
console.log('Invalid credentials');
return null;
},
}),
this produce this error in my PHPStorm IDE like this :
TS2322: Type
(credentials: Partial<Record<string, unknown>>) => Promise<User | null>
is not assignable to type
(credentials: Partial<Record<string, unknown>>, request: Request) => Awaitable<User | null>
Type Promise<User | null> is not assignable to type Awaitable<User | null>
Type Promise<User | null> is not assignable to type PromiseLike<User | null>
Types of property then are incompatible.
Type '<TResult1 = User | null, TResult2 = never>(onfulfilled?: ((value: User | null) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<...>) | null | undefined) => Promise<...>' is not assignable to type '<TResult1 = User | null, TResult2 = never>(onfulfilled?: ((value: User | null) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<...>) | null | undefined) => PromiseLike<...>'.
Types of parameters onfulfi