A promise that resolves to the authenticated user data
// Example callback function for a form strategy
const callback: Strategy.CallbackFunction<User, { form: FormData }> = async ({ form }) => {
const username = form.get("username");
const password = form.get("password");
const user = await db.user.findUnique({ where: { username } });
if (!user || !await comparePasswords(password, user.password)) {
throw new Error("Invalid username or password");
}
return user;
};
A function type for the callback used by authentication strategies.
The callback function is responsible for validating credentials extracted by the strategy and returning the corresponding user object if authentication succeeds.