# Path: flaskapp/models.py
# class User(db.Model):
#     """User object
#     """
#     id = db.Column(db.Integer, primary_key=True)
#     email = db.Column(db.String(120), index=True, unique=True, nullable=False)
#     password = db.Column(db.String(60), index=True, nullable=False)
#     is_verified = db.Column(db.Boolean(), default=False, nullable=False)
#     password_reset_requests = db.relationship(
#         'PasswordResetRequest',
#         backref=db.backref('user'))
#     email_verification_requests = db.relationship(
#         'EmailVerificationRequest',
#         backref=db.backref('user'))
# 
#     def __repr__(self):
#         return '<User %r>' % self.email
# 
#     # ===========================
#     # Flask-Login methods
#     # ===========================
#     def is_authenticated(self):
#         return True
# 
#     def is_active(self):
#         return True
# 
#     def is_anonymous(self):
#         return False
# 
#     def get_id(self):
#         return self.id
# 
# Path: flaskapp/lib/util.py
# def verify_password_hash(password, password_hash):
#     """Method to centralize the verification of password hash
#     """
#     password = password.encode('utf-8')
#     return bcrypt.hashpw(password, password_hash) == password_hash


from flask import g
from flask_wtf import FlaskForm
from wtforms import (StringField, PasswordField, BooleanField, TextAreaField,
                     FileField)
from wtforms.validators import (InputRequired, Email, URL, EqualTo,
                                ValidationError, StopValidation)
from wtforms.widgets import PasswordInput, CheckboxInput
from flaskapp.models import User
from flaskapp.lib.util import verify_password_hash
        'Email address',
        validators=[
            InputRequired('Please enter an email address'),
            Email()
            ])

    password = PasswordField(
        'Password',
        widget=PasswordInput(hide_value=False),
        validators=[
            InputRequired('Please choose a password'),
            EqualTo('password_confirm', message='Passwords must match')
            ])
    
    password_confirm = PasswordField(
        'Confirm Password',
        widget=PasswordInput(hide_value=False),
        validators=[
            InputRequired('Please confirm your password')
            ])

    newsletter = BooleanField(
        'Please send me product updates',
        widget=CheckboxInput(),
        default=True
        )

    def validate_email(form, field):
        """Check if email already exists
        """

# Path: flaskapp/models.py
# class User(db.Model):
#     """User object
#     """
#     id = db.Column(db.Integer, primary_key=True)
#     email = db.Column(db.String(120), index=True, unique=True, nullable=False)
#     password = db.Column(db.String(60), index=True, nullable=False)
#     is_verified = db.Column(db.Boolean(), default=False, nullable=False)
#     password_reset_requests = db.relationship(
#         'PasswordResetRequest',
#         backref=db.backref('user'))
#     email_verification_requests = db.relationship(
#         'EmailVerificationRequest',
#         backref=db.backref('user'))
# 
#     def __repr__(self):
#         return '<User %r>' % self.email
# 
#     # ===========================
#     # Flask-Login methods
#     # ===========================
#     def is_authenticated(self):
#         return True
# 
#     def is_active(self):
#         return True
# 
#     def is_anonymous(self):
#         return False
# 
#     def get_id(self):
#         return self.id
# 
# Path: flaskapp/lib/util.py
# def verify_password_hash(password, password_hash):
#     """Method to centralize the verification of password hash
#     """
#     password = password.encode('utf-8')
#     return bcrypt.hashpw(password, password_hash) == password_hash


# Path: flaskapp/forms.py
from flask import g
from flask_wtf import FlaskForm
from wtforms import (StringField, PasswordField, BooleanField, TextAreaField,
                     FileField)
from wtforms.validators import (InputRequired, Email, URL, EqualTo,
                                ValidationError, StopValidation)
from wtforms.widgets import PasswordInput, CheckboxInput
from flaskapp.models import User
from flaskapp.lib.util import verify_password_hash

        'Email address',
        validators=[
            InputRequired('Please enter an email address'),
            Email()
            ])

    password = PasswordField(
        'Password',
        widget=PasswordInput(hide_value=False),
        validators=[
            InputRequired('Please choose a password'),
            EqualTo('password_confirm', message='Passwords must match')
            ])
    
    password_confirm = PasswordField(
        'Confirm Password',
        widget=PasswordInput(hide_value=False),
        validators=[
            InputRequired('Please confirm your password')
            ])

    newsletter = BooleanField(
        'Please send me product updates',
        widget=CheckboxInput(),
        default=True
        )

    def validate_email(form, field):
        """Check if email already exists
        """

        u = User.query.filter(User.email == field.data).first()