def home(): form = RegistrationForm() if form.validate_on_submit(): salt_pw = ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(64)) + \ form.password.data salt_api_key = ''.join(random.SystemRandom().choice(string.ascii_uppercase + string.digits) for _ in range(64)) + \ form.password.data form.password.data += salt_pw hashed_pw = bcrypt.generate_password_hash(form.password.data).decode("utf-8") user_id = models.User.query.limit(1).all() user_id[0] += 1 api_key = user_id[0] + salt_pw + salt_api_key try: user = models.User( email=form.email.data, password=hashed_pw, address=form.address.data, api_key=api_key, salt_pw=salt_pw ) db.session.add(user) db.session.commit() return flask.redirect(flask.url_for("test")) except: flask.flash("Some error occured", category="danger") return flask.redirect(flask.url_for("/")) return flask.render_template("index.html", footer_bg="white", form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('index')) form = RegistrationForm() if form.validate_on_submit(): user = User(username=form.username.data, email=form.email.data) user.set_password(form.password.data) db.session.add(user) db.session.commit() flash('Congratulations, you are now a registered user!') return redirect(url_for('login')) return render_template('register.html', title='Register', form=form)
def register(): form = RegistrationForm(request.form) if request.method == 'POST' and form.validate(): username = form.username.data password = form.password.data if not db.find_user(username): db.add_user(username, password) return render_template('register.html', success=True) else: flash("Потребителското име вече е заето. Изберете ново") return render_template('register.html', form=form) return render_template('register.html', form=form)
def _register(self): if current_user.is_authenticated: return redirect(url_for('index')) form = RegistrationForm() if form.validate_on_submit(): usr = User(unicode(form.username.data), form.email.data, form.password.data) sql_alchemy_db.session.add(usr) sql_alchemy_db.session.commit() return redirect(url_for('login')) return render_template('register.html', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('blog')) form = RegistrationForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = User(username=form.username.data, email=form.email.data, password=hashed_password) db.session.add(user) db.session.commit() flash(f'Account created for {form.username.data}!', 'success') return redirect(url_for('login')) return render_template('register.html', title="Register", form=form)
def register(): form = RegistrationForm() if form.is_submitted(): hashed_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = User(first_name=form.first_name.data, second_name=form.last_name.data, email=form.email.data, password=hashed_password, document_number=form.document_number.data, dateOfBirth=form.dateOfBirth.data) db.session.add(user) db.session.commit() flash('Your account have been created, now You can log in', 'success') return redirect(url_for('login')) return render_template('register.html', title="Register", form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = User(username=form.username.data, email=form.email.data, password=hashed_password) db.session.add(user) db.session.commit() flash('Your account has been created! You are now able to log in.', 'success') return redirect(url_for('login')) return render_template('register.html', title='Register', form=form)
def test_missing_email(self): json = { 'username': '******', 'password': '******', 'confirm': 'password', } form = RegistrationForm.from_json(json) assert form.validate() is False
def test_missing_confirm(self): json = { 'username': '******', 'password': '******', 'email': '*****@*****.**' } form = RegistrationForm.from_json(json) assert form.validate() is False
def register(): form = RegistrationForm() if request.method == 'GET': return render_template('register.html', form=form) if request.method == 'POST': if form.validate_on_submit(): user = User(username=form.username.data, email=form.email.data) user.set_password(form.password.data) db.session.add(user) db.session.commit() return jsonify({'message': 'You are now registered!'}) else: msg = "" for fieldName, errorMessages in form.errors.items(): for err in errorMessages: msg += (fieldName + ": " + err + " ") return jsonify({'message': msg})
def test_invalid_password_combination(self): json = { 'username': '******', 'password': '******', 'confirm': 'WRONG', 'email': '*****@*****.**' } form = RegistrationForm.from_json(json) assert form.validate() is False
def test_valid(self): json = { 'username': '******', 'password': '******', 'confirm': 'password', 'email': '*****@*****.**' } form = RegistrationForm.from_json(json) assert (form.validate())
def home(): form = RegistrationForm() if form.validate_on_submit(): hashed_pw = bcrypt.generate_password_hash(form.password.data).decode("utf-8") try: user = User( email=form.email.data, password=hashed_pw, address=form.address.data ) db.session.add(user) db.session.commit() flash("Your account has been successfully registered", category="success") except: flash("Some error occured", category="danger") finally: return redirect(url_for("home")) return render_template("index.html", footer_bg="white", form=form)
def register(request): if request.method == 'POST': form = RegistrationForm(request.POST) if form.is_valid(): # newdoc = Document(docfile = request.FILES['docfile']) form.save() print(request.POST['username']) os.mkdir(settings.MEDIA_ROOT + '/' + request.POST['username']) # Redirect to the document list after POST return redirect('upload') else: form = RegistrationForm() # A empty, unbound form # Load documents for the list page # Render list page with the documents and the form return render(request, 'register/register.html', {'form_reg': form})