def __init__(self, email, password, firstname, lastname, dob): self.email = email self.password = bcrypt.generate_password_hash(password) self.firstname = firstname.lower().capitalize() self.lastname = lastname.lower().capitalize() self.dob = dob self.signup = datetime.utcnow() self.signin = datetime.utcnow() self.active = False
def __init__(self, usr_name, passwd, email, usr_type, storage_size, used_storage_size, bio, profile_pic, profession): self.usr_name = usr_name self.email = email self.passwd = bcrypt.generate_password_hash(passwd) self.usr_type = usr_type self.storage_size = storage_size self.used_storage_size = used_storage_size self.bio = bio self.profile_pic = profile_pic self.profession = profession
def reset_token(token): if current_user.is_authenticated: return redirect(url_for('main.home')) user = User.verify_reset_token(token) if user is None: flash('That is an invalid or expired token') return redirect(url_for('main.reset_request')) form = ResetPasswordForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user.password = hashed_password db.session.commit() flash('Your password has been updated! You are now able to log in') return redirect(url_for('main.login')) return render_template('reset_token.html', title='Reset Password', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() save_profile_foldername = 'profile_images' if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') if form.profile_image.data: image_file = form.profile_image.data save_profile_objectname = generate_filename(image_file) save_image(image_file, save_profile_foldername, save_profile_objectname) # for local development post_to_aws_s3(image_file, save_profile_foldername, save_profile_objectname) user = User(username=form.username.data, email=form.email.data, password=hashed_password, profile_image=save_profile_objectname) else: user = User(username=form.username.data, email=form.email.data, password=hashed_password) db.session.add(user) db.session.commit() flash('회원가입이 완료되었습니다. 로그인을 해주시기 바랍니다.', 'success') return redirect(url_for('login')) #profile_image = url_for('static', filename=save_profile_foldername + '/' + 'howwwwwhy.png')# local s3_profile_object = get_from_aws_s3( [save_profile_foldername + '/' + 'howwwwwhy.png']) s3_profile_url = s3_profile_object[0]['presigned_url'] return render_template('/auth/register.html', title='Register', form=form, profile_image=s3_profile_url) # aws s3
def on_model_change(self, form, model, is_created): # Perform some actions before a model is created or updated and # committed to the database. model.password = bcrypt.generate_password_hash( model.password).decode('utf-8')
def hash_password(self, password): return bcrypt.generate_password_hash(password)
def make_password(plaintext): return bcrypt.generate_password_hash(plaintext)
def __init__(self, email, password): self.email = email self.password = bcrypt.generate_password_hash(password) self.registered_on = datetime.now() self.signed_in = datetime.now()
def on_model_change(self, form, model, is_created): model.password = bcrypt.generate_password_hash( model.password).decode('utf-8')