Dynamic RememberMe outside of email + password?

What is the best way to implement this? Right now it seems it can only be set in either the auth config or the authClient.signIn method?
2 Replies
The Untraceable
The Untraceable2mo ago
What do you mean? In the signIn.email call it accepts a rememberMe boolean. Not sure if i understand what you mean
DN_Dev
DN_DevOP2mo ago
You can sign in with other methods like Google, Email OTP. Those don't have a remember me option If I have to use the middleware hook or something that's fine, just not sure what is the best way to go about it. Below is a code snippet for the email otp sign in option - it ignores the 3rd parameter (dontRememberMe) for createSession for some reason. I think the plugins should enforce some kind of standard, there are some that have callbackURL for e.g. but others without it, then likewise, some with errorCallbackURL.
if (ctx.context.options.emailVerification?.autoSignInAfterVerification) {
const currentSession = await getSessionFromCtx(ctx);
if (!currentSession || currentSession.user.email !== parsed.email) {
const session = await ctx.context.internalAdapter.createSession(
user.user.id,
ctx,
);
if (ctx.context.options.emailVerification?.autoSignInAfterVerification) {
const currentSession = await getSessionFromCtx(ctx);
if (!currentSession || currentSession.user.email !== parsed.email) {
const session = await ctx.context.internalAdapter.createSession(
user.user.id,
ctx,
);
createSession: async (
userId: string,
ctx: GenericEndpointContext,
dontRememberMe?: boolean,
override?: Partial<Session> & Record<string, any>,
overrideAll?: boolean,
) => {
createSession: async (
userId: string,
ctx: GenericEndpointContext,
dontRememberMe?: boolean,
override?: Partial<Session> & Record<string, any>,
overrideAll?: boolean,
) => {
And in the standard email+password sign in option it uses the third parameter as shown below
const session = await ctx.context.internalAdapter.createSession(
user.user.id,
ctx,
ctx.body.rememberMe === false,
);
const session = await ctx.context.internalAdapter.createSession(
user.user.id,
ctx,
ctx.body.rememberMe === false,
);
In my case I have 3 sign up/in options, Google, Email OTP and Email+Password. Certain things aren't consistent between them, like remember me, which if the user deselects won't work if they use the Google or Email OTP options. I can try to work around this using the hooks possibly, but then I don't know if there is some standard method to handle this so that I avoid make changes that may easily break with updates.

Did you find this page helpful?