def create_user(): request_data = request.get_json() User.create(id=request_data['id'], username=request_data['username'], email=request_data['email'], password=request_data['password'], active=True) return jsonify(msg="posted")
def register(): """Register new user.""" form = RegisterForm(request.form, csrf_enabled=False) if form.validate_on_submit(): User.create(username=form.username.data, email=form.email.data, password=form.password.data, active=True) flash('Thank you for registering. You can now log in.', 'success') return redirect(url_for('public.home')) else: flash_errors(form) return render_template('public/register.html', form=form)
def register(): """Register new user.""" form = RegisterForm(request.form) if form.validate_on_submit(): User.create(username=form.username.data, email=form.email.data, password=form.password.data, active=True) flash('Thank you for registering. You can now log in.', 'success') return redirect(url_for('public.home')) else: flash_errors(form) return render_template('public/register.html', form=form)
def test_check_password(self): """Check password.""" user = User.create(username='******', email='*****@*****.**', password='******') assert user.check_password('foobarbaz123') is True assert user.check_password('barfoobaz') is False
def test_check_password(self): """Check password.""" user = User.create(username="******", email="*****@*****.**", password="******") assert user.check_password("foobarbaz123") is True assert user.check_password("barfoobaz") is False
def run(user): user = User.create(username="******", email="*****@*****.**", password="******", active=True, first_name="admin", last_name="admin", admin=True, confirmed=True, confirmed_on=datetime.datetime.now()) user.save()
def register(): """Register new user.""" form = RegisterForm(request.form) if form.validate_on_submit(): user = User.create(username=form.username.data, email=form.email.data, password=form.password.data, active=False) flash( 'Thank you for registering. Please validate your email ' 'address before logging in.', 'success') send_confirm_email(user) return redirect(url_for('public.home')) else: flash_errors(form) return render_template('register.html', form=form)
def register(): """Register new user.""" form = RegisterForm(request.form, csrf_enabled=False) if form.validate_on_submit(): user = User.create(username=form.username.data, email=form.email.data, password=form.password.data, first_name=form.firstname.data, last_name=form.lastname.data, active=True, confirmed=False) email = form.email.data token = generate_confirmation_token(email) confirm_url = url_for('public.confirm_email', token=token, _external=True) html = render_template('public/email_templates/confirm.html', confirm_url=confirm_url) subject = "Please confirm your email" send_mailgun_email(email, subject, html) login_user(user) flash('Thank you for registering, a confirmation email has been sent', 'success') return redirect(url_for('public.unconfirmed')) else: flash_errors(form) return render_template('public/register.html', form=form)
def run(self, username, email, password, new_password, **options): if password is None: password = uuid.uuid4().__str__().replace('-', '') logger.info("User created: %s, %s. With password: %s" % (username, email, password)) query_set = User.query.filter(User.email == email) if query_set.count() is 0: user = User.create(username=username, email=email, password=password, active=True, first_name=options.get('firstname', email.split('@')[0]), last_name=options.get('lastname', email.split('@')[0])) else: if new_password is False: raise ValueError("User Exists") user = query_set.first() user.set_password(password) user.save() logger.info("User password renewed")
def test_check_password(self): user = User.create(username="******", email="*****@*****.**", password="******") assert user.check_password('foobarbaz123') is True assert user.check_password("barfoobaz") is False