What I’m trying to do:
Set up the User Authentication service in my app so users can sign up and log in
What I’ve tried and what’s not working:
Following the tutorial and double-checking my app dependencies, when I click the “sign up” button nothing happens and when I click “log in” it brings up the login menu but there is no “cancel” button to exit the prompt.
Code Sample:
from ._anvil_designer import Form1Template
from anvil import *
import anvil.tables as tables
import anvil.tables.query as q
from anvil.tables import app_tables
import anvil.users
import custom_signup.login_flow
class Form1(Form1Template):
def init(self, **properties):
# Set Form properties and Data Bindings.
self.init_components(**properties)
self.update_login_status()
# Any code you write here will run before the form opens.
def login_button_click(self, **event_args):
“”“This method is called when the button is clicked”“”
custom_signup.login_flow.login_with_form()
self.update_login_status()
def update_login_status(self):
# Get the currently logged in user (if any)
user = anvil.users.get_user()
if user is None:
self.login_status.text = “You are not logged in”
else:
self.login_status.text = f"You are logged in as {user[‘email’]}"
def signup_button_click(self, **event_args):
“”“This method is called when the button is clicked”“”
def signup_button_click(self, **event_args):
custom_signup.login_flow.signup_with_form()
self.update_login_status()
pass
**Clone link:**
https://anvil.works/build#clone:6WISW6G7CNAX6EJY=3TUIN4HNGGOZMU7CIAYM7TVG|EFFIISC235SVCCY2=TP7THO2XZJBKYJHT265RRFBF
*share a copy of your app*
Welcome to the forum!
Just checking, are you meaning to use a custom login flow (the one where you get to customize the look and feel of the login and signup forms)? Or are you trying to use the built-in Anvil authentication?
Your code is using the custom flow. If that’s what you’re intending, you have control over those forms and can edit them in the dependency, or look at their code in the dependency.
If you’re just trying to get login working and don’t care how, I’d use the built-in Anvil authentication: Anvil Docs | Presenting a Login Form
Hello, thank you for your response.
Yes, I am attempting to use the custom signup flow. I was able to figure out the issue with my login button that was not working, I had accidentally put two lines of the same code and it messed things up with my function. Now I am having trouble where I don’t have a cancel or “X” button when bringing up the signup form. I may use Anvil’s built-in authentication to make things easier. Thank you for providing that resource.
If you want a cancel button with the custom login flow, you’d need to go into the dependency and modify the custom login/register forms to provide a cancel button.
Honestly, though, if you don’t need a custom login flow I’d just use Anvil’s built-in authentication.
My problem is related to it, I have customize login and signup form and now want to have 2FA and signup and login with google and all these step in my customize form, how can I do all these steps in my customize forms?
You should make a separate question thread for your issues as they are different than this stale question thread. Also please provide more details as to what you have for a custom flow so far.