Remember me for signin.emailOtp

Loving this library but Im stuck trying to setup remember me. It seems to be in signin.email() but not signin.emailOtp().

I attempted to use a before hook middleware to make the login session but couldn't figure it out.

How should I go about setting this up?

Any help would be appreciated!
Solution
// Frontend
authClient.signIn.emailOtp(
    {
        otp: code,
        email: search.email,
    },
    {
        body: {
            rememberMe,
        },
    },
),

// Auth hook
hooks: {
    after: createAuthMiddleware(async (ctx) => {
        if (ctx.path == "/sign-in/email-otp") {
            const session = ctx.context.newSession;
            const dontRememberMe = !ctx.body.rememberMe;

            if (session && dontRememberMe) {
                // Sets the session and dont_remember cookies
                await setSessionCookie(ctx, session, dontRememberMe);

                // Updates the session expiry to 1 day (matches default remember me config)
                await ctx.context.internalAdapter.updateSession(
                    session.session.token,
                    {
                        expiresAt: new Date(
                            Date.now() + 24 * 60 * 60 * 1000,
                        ),
                    },
                );
            }
        }
    }),
},

Think I fixed it with this. I attempted to match how it is setup in the default email login. I believe it is just setting the cookies with the dontRememberMe option and session expiry, then everything else should be handled the same as the default login.
Was this page helpful?