Authorize function expect to return Awaitable<User / null>
Unanswered
Standard Chinchilla posted this in #help-forum
Standard ChinchillaOP
export const { auth, signIn, signOut } = NextAuth({
...authConfig,
providers: [
Credentials({
async authorize(credentials) {
const parsedCredentials = z
.object({ email: z.string().email(), password: z.string().min(8) })
.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;
},
}),
],
});I'm getting a type error the authorize function should return Awaitable<User/null> but it's returning Promise<User/null>
What's the reason for this error and how can I fix this?
Error:-
Type '(credentials: Partial<Record<string, unknown>>) => Promise<User | null | undefined>' is not assignable to type '(credentials: Partial<Record<string, unknown>>, request: Request) => Awaitable<User | null>'.2 Replies
Toyger
https://github.com/nextauthjs/next-auth/issues/2701
just change strict or better ts-ignore as mentioned in comments
just change strict or better ts-ignore as mentioned in comments
@Toyger https://github.com/nextauthjs/next-auth/issues/2701
just change strict or better ts-ignore as mentioned in comments
Standard ChinchillaOP
I also ignored the error using ts-ignore, but I thought I'm doing something wrong.