mrrichardasmith / family_vote

Voting for the Democratic Family
0 stars 0 forks source link

Create User Registration form #13

Open mrrichardasmith opened 2 years ago

mrrichardasmith commented 2 years ago

As a developer wanting to provide a registration form to add users to the database from which to authenticate Given that we need another form to collect the registration details create a registration form class and pass in FlaskForm Then include a second password field using the EqualTo('password') method to ensure the password entered is as the user intended. When the class is built create an object with it inside a route and pass the variable to the template where the fields need to be used and validated.

mrrichardasmith commented 2 years ago

class RegistrationForm(FlaskForm): username = StringField('Username', validators=[DataRequired()]) email = StringField('Email', validators=[DataRequired(), Email()]) password = PasswordField('Password', validators=[DataRequired()]) password2 = PasswordField( 'Repeat Password', validators=[DataRequired(), EqualTo('password')]) submit = SubmitField('Register')