Magic Link and Remember Logins - Does this work?

I have magic link authentication turned on and my users are complaining they have to login every couple of hours, even though I have the remember login state set to 1-year.

When I look at the user tables, the remember_logins column is None for all rows.

Should this work?

:thinking:

What happens if you put a server call right after the login splash screen that calls the server module and does a anvil.users.get_user() to get the user row, then passes the user row to anvil.users.force_login(user_row)

Will it create the entry in the remembered_logins column of the users table?

@ianb

Sorry for the delayed response.

Just did this …

@anvil.server.callable
def force_user():
  my_logger.debug("ENTERING: force_user")
  cur_user = anvil.users.get_user()
  my_logger.debug(f"CUR USER: {cur_user}")
  anvil.users.force_login(cur_user)
  my_logger.debug("forced a login")

And in the Users table, the last_login is now populated but the remembered_logins is still blank.

@ianb

Now trying this variant:

@anvil.server.callable
def force_user():
  my_logger.debug("ENTERING: force_user")
  cur_user = anvil.users.get_user()
  my_logger.debug(f"CUR USER: {cur_user}")
  anvil.users.force_login(cur_user, remember=True)
  my_logger.debug("forced a login")

Will have to wait some time to see of the remembering is working, but at least the column in the users table has data.

Are you able to create a minimal example to replicate the issue and share a clone link?

Does this mean it works for you?

I’m juggling a few different projects and am in the midst of being nomadic … so my capacity is extremely constrained to do much beyond critical/urgent tasks.

No I do not use this feature.

Looking at the anvil-runtime source code…it appears that remembering who is logged in is not a feature of the magic link method.

Your latest workaround will probably work.

I’m sorry for resurrecting this old thread, but I just encountered the same issue. @meredydd Has this been classed as a bug? For the user, the behaviour is clearly not what the interface suggests.

The workaround does indeed successfully remember the login, but because it does not capture the value of the ā€œRemember meā€ checkbox, it’s not fully functional. It always remembers the login, regardless of whether the user checked the box, so now the behaviour is wrong in the other direction.

Hi all!

I’ve been able to recreate this. I’ll raise the issue internally to figure out the intended behavior and get a fix shipped if necessary. I’ll update this thread when I have more info!

2 Likes