def process_reg(): form = RegistrationForm() if form.validate_on_submit(): new_user = User(username=form.username.data, email=form.email.data, role='user') if form.first_name.data: new_user.first_name = form.first_name.data if form.last_name.data: new_user.last_name = form.last_name.data if form.city.data: new_user.city = form.city.data new_user.set_password(form.password.data) db.session.add(new_user) db.session.commit() flash('Вы успешно зарегистрировались') return redirect(url_for('login')) else: for field, errors in form.errors.items(): for error in errors: flash('Ошибка в поле {}: {}'.format( getattr(form, field).label.text, error)) return redirect(url_for('register'))
def process_registration(): form = RegistrationForm() if form.validate_on_submit(): email = form.email.data username = form.username.data password = form.password_reg.data password_confirm = form.password_reg_confirm.data if Users.query.filter(Users.email == email).count(): logging.error('Такой пользователь уже есть') flash('Такой пользователь уже есть') return redirect(url_for('login')) if not password == password_confirm: logging.error('Пароли не совпадают') flash('Пароли не совпадают. Повторите ввод') return redirect(url_for('registration')) new_user = Users(email=email, username=username) new_user.set_password(password) db.session.add(new_user) db.session.commit() flash('Вы успешно зарегистрировались') return redirect(url_for('login')) logging.error('Пароль не соответствует требованиям') flash('Пароль должен содержать хотя бы одну заглавную букву,' 'хотя бы одну цифру и быть не менее 8 символов') return redirect(url_for('registration'))
def regisration(): title = "Регистрация в Apotheka" login_form = RegistrationForm(request.form) if request.method == 'POST' and login_form.validate(): user = User(username=login_form.user_name.data, email=login_form.email.data, userTelegrammChat=request.form.get("telegram")) try: user.set_password(login_form.password.data) db.session.add(user) db.session.commit() profile = Profile( user_id=user.id, name=login_form.Name.data, sername=login_form.Sername.data, age=int(login_form.age.data), isWoman=( # Не уверен на счет верности переноса str_to_bool(request.form.get("gender")))) db.session.add(profile) db.session.commit() flash('Спасибо за регистрацию') return redirect(url_for('login')) except IntegrityError: flash('Пользователи с такими данными уже существуют') return redirect(url_for('regisration')) return render_template('/user/registration.html', title=title, form=login_form, User="", Profile="")
def register(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() db.create_all() def Key_api_generator(): key_api = secrets.token_hex(16).encode('utf-8') return key_api 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, key_api=Key_api_generator()) db.session.add(user) db.session.commit() flash( 'Your account has been created! You are now able to log in! An Account KEY is sent to your email', 'success') path = 'webapp/trained_img/' + user.username os.mkdir(path) user1 = user.username return redirect(url_for('login')) return render_template('register.html', title='Register', form=form)
def process_registration(): form = RegistrationForm() if form.validate_on_submit(): username = form.username_reg.data password = form.password_reg.data if Users.query.filter(Users.email == username).count(): flash('Такой пользователь уже есть') logging.error('Такой пользователь уже есть') return redirect(url_for('registration')) new_user = Users(email=username) new_user.set_password(password) db.session.add(new_user) db.session.commit() flash('Вы успешно зарегистрировались') return redirect(url_for('index')) flash('Пароль не удовлетворяет требованиям. Повторите ввод') logging.error('Форма не провалидировалась, Ошибка в пароле.') return redirect(url_for('registration'))
def register(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): user = User(username=form.username.data, email=form.email.data) user.set_password(form.password.data) user.save() return redirect(url_for('login')) return render_template('register.html', title='Register', form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): user = User(username=form.username.data, email=form.email.data) user.set_password(form.password.data) wappdb.session.add(user) wappdb.session.commit() flash('Se ha registrado el usuario nuevo.') return redirect(url_for('index')) return render_template('register.html', title='Register', form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): user = User(username=form.username.data, password=form.password.data) db.session.add(user) db.session.commit() flash('Thanks for registering! Now you can login!') return redirect(url_for('auth.login')) return render_template('register.html', form=form)
def registration(): 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('You are now registered user!') return redirect(url_for('login')) return render_template('registration.html', title='Register', form=form)
def register(): if current_user.is_authenticated: ## DEBUG: doens't work # TODO: if logged in redirect to home return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash(form.password.data).decode('utf-8') # hashes entered password user = User(username=form.username.data, email=form.email.data, password=hashed_password) # create user instance with input from form db.session.add(user) db.session.commit() # adds user to database 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 request.method == 'POST' and form.validate(): username = form.username.data email = form.email.data password = form.password.data user = User(username, email, password) db.session.add(user) db.session.commit() return redirect(url_for("login")) return render_template("register.html", form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): new_user = User(form.username.data) new_user.set_password(form.password.data) db.session.add(new_user) db.session.commit() flash("Your user has been created, please login.", category='success') return redirect(url_for('.login')) return render_template('register.html', 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(email=form.email.data, password=hashed_password) user.add() 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 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(email=form.email.data, password=hashed_password) user.add() 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 register(): form = RegistrationForm() if form.validate_on_submit(): user = User(username=form.username.data, email=form.email.data) user.set_password(form.password.data) user.new_id() wappdb.session.add(user) wappdb.session.commit() flash('New user has been registered.') login_user(user, remember=False) return redirect(url_for('index')) return render_template('register.html', title='Discord Herald Registration', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): hashed_pw = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = User(username=form.username.data, password_hash=hashed_pw, email=form.email.data, admin=False).save() flash('Account for ' + form.username.data + ' created successfully!', '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(f'Your Account has been created!', 'success') return redirect(url_for('home')) return render_template('register.html', title='Register', 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.lower(), email=form.email.data) user.set_password(form.password.data) db.session.add(user) db.session.commit() flash('Your account has been successfully created') return redirect(url_for('login')) return render_template('register.html', title='New Account', header_title='Create New Account', form=form)
def register(): if current_user.is_authenticated: return redirect("/home") form = RegistrationForm() if form.validate_on_submit(): user = User(username=form.username.data) user.set_password(form.password.data) db.session.add(user) db.session.commit() flash("New user created") return redirect("/index") return render_template("register.html", form=form, title="Register")
def register(): form = RegistrationForm() if request.method == 'POST': id_base = str(form.email.data + form.email.data) id = str( base64.urlsafe_b64encode( hashlib.md5(str(id_base).encode('utf-8')).digest()), 'utf-8').rstrip("=")[0:15] matches = User.query.filter_by(id=id).paginate().total while matches: id_base = id_base + "1" id = str( base64.urlsafe_b64encode( hashlib.md5(str(id_base).encode('utf-8')).digest()), 'utf-8').rstrip("=")[0:15] matches = User.query.filter_by(id=id).paginate().total new_user = User(id=id, firstname=form.firstname.data, lastname=form.lastname.data, username=form.username.data, email=form.email.data, password=form.password.data, role="user") db.session.add(new_user) db.session.commit() login_user(new_user) return redirect(url_for('registered')) return render_template('register.html', title='Register', form=form)
def register(): if current_user.is_authenticated: return redirect(url_for('index')) title = 'Регистрация' registration_form = RegistrationForm() return render_template('registration.html', page_title=title, form=registration_form)
def registration_view(request): if request.method == "POST": rform = RegistrationForm(request.POST) if rform.is_valid(): fname = request.POST.get('first_name') lname = request.POST.get('last_name') uname = request.POST.get('user_name') pwd = request.POST.get('password') mobile = request.POST.get('mobile') email = request.POST.get('email') data = RegistrationData(first_name=fname, last_name=lname, user_name=uname, password=pwd, mobile=mobile, email=email) data.save() rform = RegistrationForm() return render(request, 'movie_htmlfiles/reg.html', {'rform': rform}) else: return HttpResponse('USer Invalid Data') else: rform = RegistrationForm() return render(request, 'movie_htmlfiles/reg.html', {'rform': rform})
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(f"Account created for {form.username.data}! You were logged in!", "success") login_user(user) next_page = request.args.get("next") return redirect(next_page) if next_page else redirect(url_for("home")) return render_template("register.html", form=form)
def register(): if current_user.is_authenticated: flash('Вы уже зарегистрировались и вошли на сайт') return redirect(url_for('index')) form = RegistrationForm() title = "Регистрация" return render_template('registration.html', page_title=title, form=form)
def process_reg(): form = RegistrationForm() if form.validate_on_submit(): new_user = User(username=form.username.data, email=form.email.data, role='user') new_user.set_password(form.password.data) db.session.add(new_user) db.session.commit() flash('Вы успешно зарегистрировались!') return redirect(url_for('login')) else: for field, errors in form.errors.items(): for error in errors: flash('Ошибка в поле "{}": - {}'.format( getattr(form, field).label.text, error)) return redirect(url_for('register')) flash('Пожалуйста, исправьте ошибки в форме') return redirect(url_for('register'))
def register_expert(request): if request.method == 'POST': form = RegistrationForm(request.POST, request.FILES) if form.is_valid(): form.save() username = form.cleaned_data['email'] password = form.cleaned_data['password1'] #Log user in user = authenticate(username = username, password = password) login(request, user) create_thumbnail(username) subject = "New Expert Registration on Local Experts" message = "New expert joined Local Experts. | Email: " + username + " | Category_id: " + str(user.category_id) + " | District: " + user.district from_email = settings.EMAIL_HOST_USER password = settings.EMAIL_HOST_PASSWORD to_list = ['*****@*****.**'] send_mail(subject, message, from_email, to_list, fail_silently=True) return redirect('/webapp/expert?id='+str(user.id)) else: #When form invalid form = RegistrationForm(request.POST) expertieses = Expertise.objects.all() context = { 'form' : form, 'expertieses' : expertieses } return render(request, 'registration/register_expert.html', context) else: form = RegistrationForm() expertieses = Expertise.objects.all() context = { 'form' : form, 'expertieses' : expertieses } return render(request, 'registration/register_expert.html', context)
def register(): if current_user.is_authenticated: flash('You are already logged in', 'success') return redirect(url_for('home')) form = RegistrationForm() if form.validate_on_submit(): # hash the pw hashed_pw = bcrypt.generate_password_hash( form.password.data).decode('utf-8') # crewate user user = User(username=form.username.data, email=form.email.data, password=hashed_pw) # add user to DataBase db.session.add(user) db.session.commit() flash('Your account has been created, you may now log in', 'success') return redirect(url_for('login')) #function name return render_template('register.html', title='Register', form=form)
def registration(): if current_user.is_authenticated: flash('Вы уже авторизованы') return redirect(url_for('search')) title = "Регистрация" registration_form = RegistrationForm() return render_template('registration.html', page_title=title, form=registration_form, active='registration')
def registration(): if current_user.is_authenticated: logging.error('Вы уже авторизованы') flash('Вы уже авторизованы') return redirect(url_for('index')) title = "Регистрация" registration_form = RegistrationForm() return render_template('page-registration.html', title=title, form=registration_form, active='registration')
def register_client(request): if request.method == 'POST': form = RegistrationForm(request.POST, request.FILES) if form.is_valid(): form.save() username = form.cleaned_data['email'] password = form.cleaned_data['password1'] #Log user in user = authenticate(username = username, password = password) login(request, user) subject = "New Client Registration on Local Experts" message = "New client joined Local Experts. | Email: " + username from_email = settings.EMAIL_HOST_USER password = settings.EMAIL_HOST_PASSWORD to_list = ['*****@*****.**'] send_mail(subject, message, from_email, to_list, fail_silently=True) return redirect('/?just_registered=true') else: #print form.errors #When form invalid form = RegistrationForm(request.POST) context = { 'form' : form } return render(request, 'registration/register_client.html', context) else: form = RegistrationForm() context = { 'form' : form } return render(request, 'registration/register_client.html', context)