Single login only at once

Similar to what @jshaffstall says, something like this may work:

  • When a user signs in, it calls a server function called new_sign_in
  • The new_sign_in function gets the session id with anvil.server.get_session_id() and stores it in the Users table
  • Every time the app does a server call, every server callable checks if the anvil.server.get_session_id() matches the session id stored in the Users table, and…
    – if it doesn’t, it will return an error to let the form know that it needs to sign out
    – if it does, it will do its job and return whatever it needs to return
  • Optionally, a timer in the form calls the server function called check_other_sign_in every 5 seconds, and if the function returns True, the app shows a notification and signs out
1 Like