def __init__(self, email, password, admin=False):
     self.email = email
     self.password = bcrypt.generate_password_hash(
         password, app.config.get('BCRYPT_LOG_ROUNDS')
     ).decode('utf-8')
     self.registered_on = datetime.datetime.now()
     self.admin = admin
Exemple #2
0
 def __init__(self, username=None, email=None, password=None, admin=False):
     self.username = username
     self.email = email
     self.admin = admin
     self.password = bcrypt.generate_password_hash(
         password,
         current_app.config.get('BCRYPT_LOG_ROUNDS')).decode('utf-8')
     self.registered_on = datetime.datetime.now()
Exemple #3
0
def register():
    form = RegisterForm(request.form)
    if form.validate_on_submit():
        user = models.User(
            username=form.username.data,
            email=form.email.data,
            password=bcrypt.generate_password_hash(
                form.password.data,
                current_app.config.get('BCRYPT_LOG_ROUNDS')).decode('utf-8'),
            admin=False)

        user.save()

        login_user(user)
        flash('You are logged in. Welcome to Gallery!', 'success')
        return redirect(url_for('user.main'))

    return render_template('user/register.html', form=form)
Exemple #4
0
 def set_password(self, password: str):
     self.password_hash = bcrypt.generate_password_hash(password)
Exemple #5
0
 def __init__(self, name, email, password):
     self.name = name
     self.email = email
     self.password = bcrypt.generate_password_hash(
         password, app.config.get('BCRYPT_LOG_ROUNDS')).decode()
     self.registered_on = datetime.datetime.now()
Exemple #6
0
 def set_password(self, password: str):
     self.password_hash = bcrypt.generate_password_hash(password)