explore-flask
explore-flask copied to clipboard
Handling Users
Hi Robert,
Thank you very much for your excellent book. My apologies in advance if this is an obvious answer as I am somewhat new to flask. In this chapter, it seems you describe several account creation methods - "create_account" and "signup" to be specific - which don't appear to work together. Also, you only describe a User model once, and it only contains columns for 'username' and '_password', whereas earlier you mention creating an instance of the User class with 'email' and 'password', as well as an 'email_confirmed' boolean. I am confused as to if this chapter is meant to have any coherence throughout the code samples or if I am missing the logic. I see most of the snippets building off of eachother and then some not at all.
Thanks for your thoughts in advance, Mark
I think in views.py
you can add the email_confirmed = False
value.
...
def create_account():
form = EmailPasswordForm()
if form.validate_on_submit():
user = User(
email = form.email.data,
email_confirmed = False,
password = form.password.data
)
db.session.add(user)
db.session.commit()
Then def confirm_email(token):
should be just an update where this is changed to False. Would this be enough @rpicard?
@markgalup The chapter isn't meant to have coherence through the code samples. Each is just meant to illustrate a specific point.
@martinbel I think it's easier to specify the default value of False
for the email_confirmed
column in the database model, but however it gets set works.