If all you really want is whether the user is logged in in any way, you can use the @anvil.server.callable()
decorator itself with parameters.
# verify that a user is logged in using the Users Service
@anvil.server.callable(require_user=True)
require_user
can take a boolean value (as above), or a function. If given a function, that function will receive the currently logged-in user (the return value of anvil.users.get_user()
).
From the docs here: