**What I’m trying to do: I’m trying to have a button (it’s a link component) show as either Login/Signup or Sign Out depending on if a user is logged in by the following:
anvil.users.get_user()
What I’ve tried and what’s not working:
Not sure if
Code Sample: No code
Clone link:
Welcome to the forum!
Links have a text
property. You can set that property to whatever you want the user to see, if you want to change one link to show something else.
Another common technique is to make links visible/invisible using the visible
property. With that technique you’d set the login and sign up links to be visible and the logout link to be invisible if there is no user logged in.
Also, note that you’re using anvil.users.login_with_form() in server code. That’s a client side call, and won’t work in server code.
Thanks! Got to your message late but it worked using text property:
- I updated the self.item dictionary in the init of my main layout form
- I created a function within the same main layout form to output “Log out” or “Log in” depending on if anvil.users.get_user() is None or not (i.e. if someone is logged in or not).
- I then updated my text property of the component I wanted to be dynamic.