remix-auth - v5.0.0
    Preparing search index...

    Type Alias CallbackFunction<SessionData, CallbackOptions>

    CallbackFunction: (options: CallbackOptions) => Promise<SessionData>

    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.

    Type Parameters

    • SessionData
    • CallbackOptions

    Type Declaration

    Should throw an appropriate error if authentication fails (e.g., invalid credentials)

    // 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;
    };