def post(self): post_data = request.get_json() try: user = user = User.query.filter_by(id=post_data.get('user_id')).first() if user: user.password = bcrypt.generate_password_hash( post_data.get('password'), app.config.get('BCRYPT_LOG_ROUNDS') ).decode() db.session.add(user) db.session.commit() responseObject = { 'status': 'success', 'message': 'You have changed your password. Please Login.' } return make_response(jsonify(responseObject)), 200 else: responseObject = { 'status': 'fail', 'message': 'User could not be found.' } return make_response(jsonify(responseObject)), 501 except Exception as e: print(e) responseObject = { 'status': 'fail', 'message': 'That user could not be found. Please register.' } return make_response(jsonify(responseObject)), 500
def forgot_new(token): reset_data = request.json logging.info('forget token db call') user = Users.query.filter_by(password_reset_token=token).first() logging.info('forget token db call success') if user is not None: user.password = bcrypt.generate_password_hash(reset_data['password']) user.password_reset_token = None try: db.session.commit() logging.info('forget token exiting') return render_template( 'sar-Response.html', SAR_response='Password successfully changed.') except (sqlalchemy.exc.SQLAlchemyError, sqlalchemy.exc.DBAPIError) as e: logging.info('forget token exiting') db.session.rollback() return wrapper.wrapper(None, e.message, 500), 500 else: logging.info('forget token exiting') return render_template( 'sar-Response.html', SAR_response='Password change was unsuccessful.')
def __init__(self, email, password, admin=False): self.email = email self.password = bcrypt.generate_password_hash( password, app.config.get('BCRYPT_LOG_ROUNDS')).decode() self.registered_on = datetime.datetime.now() self.admin = admin self.core_banking_identifier = None
def __init__(self, email, password, admin=False): self.email = email self.password = bcrypt.generate_password_hash( password, app.config.get('BCRYPT_LOG_ROUNDS') ) self.registered_on = datetime.datetime.now() self.admin = admin
def __init__(self, email, password, admin=False): self.email = email self.password = bcrypt.generate_password_hash( password, current_app.config.get("BCRYPT_LOG_ROUNDS")).decode("utf-8") self.registered_on = datetime.datetime.now() self.admin = admin
def __init__(self, system_name, username, password, is_admin=False): self.system_name = system_name self.username = username self.password = bcrypt.generate_password_hash( password, app.config.get('BCRYPT_LOG_ROUNDS')).decode() self.registered_at = datetime.datetime.now() self.last_activity_at = datetime.datetime.now() self.is_admin = is_admin
def __init__(self, email, nickname, password, admin=False): self.nickname = nickname self.email = email self.password = bcrypt.generate_password_hash( password, current_app.config.get('BCRYPT_LOG_ROUNDS')).decode('utf-8') self.registered_on = datetime.datetime.now() self.admin = admin
def __init__(self, **kwargs): self.username = kwargs.get('username') self.email = kwargs.get('email', None) self.password = bcrypt.generate_password_hash( kwargs.get('password'), app.config.get('BCRYPT_LOG_ROUNDS')) self.registered_on = datetime.datetime.now() self.admin = kwargs.get('admin') self.last_login = datetime.datetime.now()
def __init__(self, email, password, user_role): self.email = email self.password = bcrypt.generate_password_hash( password, app.config.get('BCRYPT_LOG_ROUNDS')).decode() self.created_on = datetime.datetime.now() self.modified_on = datetime.datetime.now() self.user_role = user_role self.verified = 'NotVerified'
def __init__(self, email, password, is_superuser=False, **kwargs): super(User, self).__init__(**kwargs) self.email = email self.password = bcrypt.generate_password_hash( password, app.config.get('BCRYPT_LOG_ROUNDS')).decode() self.last_request = datetime.datetime.now() self.registered_on = datetime.datetime.now() self.is_superuser = is_superuser
def __init__(self, email, password, username, admin=False, id=None): self.email = email self.username = username self.password = bcrypt.generate_password_hash( password, app.config.get('BCRYPT_LOG_ROUNDS') ).decode() self.registered_on = datetime.datetime.now() self.admin = admin self.id = id
def reset_password(): form = ResetPasswordForm(request.form) if form.validate_on_submit(): user = User.query.filter_by(id=current_user.id).first() user.password = bcrypt.generate_password_hash( form.password.data, app.config.get('BCRYPT_LOG_ROUNDS') ).decode('utf-8') db.session.commit() flash('Password Reset Successfully!', 'success') return redirect(url_for('main.home')) return render_template('user/passwordreset.html', form=form)
def password(): form = PasswordForm(request.form) if form.validate_on_submit(): user = User.query.filter_by(id=current_user.get_id()).first() user.password = bcrypt.generate_password_hash(form.password.data) try: db.session.commit() flash('Password Updated!', 'success') return redirect(url_for('main.home')) except exc.SQLAlchemyError: flash('Something went wrong.', 'danger') return redirect(url_for('main.home')) return render_template('user/password.html', form=form)
def __init__(self, email, password, bday, fullname, job=None, country=None): self.email = email self.password = bcrypt.generate_password_hash( password, app.config.get('BCRYPT_LOG_ROUNDS')).decode() self.registered_on = datetime.datetime.now() self.bday = bday self.fullname = fullname self.country = country self.job = job
def __init__(self, data, confirmed, confirmed_on=None, token=None,user_type=None,user_group=None): self.name = data["name"] self.email = data["email"] self.password = bcrypt.generate_password_hash( data["password"], current_app.config.get('BCRYPT_LOG_ROUNDS') ).decode('utf-8') self.user_type = user_type self.user_group = user_group self.phone = data["phone"] self.creation_time = datetime.datetime.now() # self.modification_time = data["modification_time"] self.created_by = data["created_by"] self.modified_by = data["modified_by"] self.confirmed = confirmed self.confirmed_on = confirmed_on self.token = token
def __init__(self, email, password, admin=False): """ Calling a new instance of this class runs this __init__ function. This is how a new user is created. """ # Assign the values to the class instance, this populates # the SQL row entries. self.email = email # TODO: Comment this, explain what is happening here and # what is actually saved in the row. self.password = bcrypt.generate_password_hash( password, current_app.config.get('BCRYPT_LOG_ROUNDS')).decode('utf-8') # Save what time the user was created. self.registered_on = datetime.datetime.now() # Set the administrator boolean value. self.admin = admin
def __init__(self, email, password, username, first_name, last_name, company_id, phone_number='', nid='', profile_photo='', member_type=''): self.email = email self.password = bcrypt.generate_password_hash( password, app.config.get('BCRYPT_LOG_ROUNDS')).decode() self.registered_on = datetime.now() self.username = username self.first_name = first_name self.last_name = last_name self.company_id = company_id self.phone_number = phone_number self.nid = nid self.profile_photo = profile_photo self.member_type = member_type
def __init__( self, user_name, email, password, admin=False, first_name="", last_name="", profile_status="private", profile_pic="https://s3.amazonaws.com/cerebro-kassellabs-data/public/default-user-image.png", about_me="", location="", age=None, website="#", facebook_url="#", twitter_url="#", ): self.user_name = user_name 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.last_login = datetime.datetime.now() self.admin = admin self.first_name = first_name self.last_name = last_name self.profile_status = profile_status self.profile_pic = profile_pic self.about_me = about_me self.location = location self.age = age self.website = website self.facebook_url = facebook_url self.twitter_url = twitter_url
def __init__(self, email, password): self.email = email self.password = bcrypt.generate_password_hash(password) self.registered_on = datetime.datetime.now()
def get_digest(cls, string): return bcrypt.generate_password_hash( string, current_app.config.get("BCRYPT_LOG_ROUNDS")).decode("utf-8")
def __init__(self, registration_id, password, role_id): self.registration_id = registration_id self.password = bcrypt.generate_password_hash( password, app.config.get('BCRYPT_LOG_ROUNDS')).decode() self.role_id = role_id
def get_password_hash(password): return bcrypt.generate_password_hash( password, app.config.get('BCRYPT_LOG_ROUNDS')).decode()
def set_password(self, password): """Set password.""" self.password = bcrypt.generate_password_hash(password)
def __init__(self, email, password, admin=False): self.email = email self.password = bcrypt.generate_password_hash( password, app.config.get('BCRYPT_LOG_ROUNDS')).decode()
def __init__(self, name, email, password, admin=False): self.email = email self.password_hash = bcrypt.generate_password_hash(password) self.name = name
def clean(self): self.password = bcrypt.generate_password_hash( self.password, app.config.get('BCRYPT_LOG_ROUNDS')).decode()