Hi,
Not sure if it helps but I have a similar approach based on that example. However in my app the actual ‘login’ happens from the client not the server. The server call only returns if an error was found.
if choice == 'login':
username = d.username_box.text
user_email = f"{username}@blobber.nl"
err = anvil.server.call('_user_login', user_email, username, d.password_box.text)
if err is not None:
d.login_err_lbl.text = err
d.login_err_lbl.visible = True
else:
try:
anvil.users.login_with_email(user_email, d.password_box.text, remember=True)
except anvil.users.AuthenticationFailed as e:
d.login_err_lbl.text = str(e.args[0])
d.login_err_lbl.visible = True