def create_user(cls, **kwargs): user = User() user.active = kwargs.get('active', True) user.email = kwargs.get('email', cls.fake.email()) user.initials = kwargs.get( 'initials', cls.fake.pystr(min_chars=1, max_chars=4), ).upper() user.name = kwargs.get('name', cls.fake.name()) user.password = User.encrypt_password( kwargs.get('password', cls.fake.password()), ) return user.save()
def sign_up_POST(): form = SignUpForm(request.form) if not form.validate_on_submit(): return render_template('auth/sign-up.html', form=form), 400 user = User() form.populate_obj(user) user.initials = User.create_initials(user.name) user.password = User.encrypt_password(form.password.data) user.save() send_verification_email(user) return redirect(url_for('auth.verify_resend_GET', email=form.email.data))