def tournaments(): products = Addproduct.query.filter(Addproduct.stock > 0).order_by(Addproduct.id.desc()) product = Addproduct.query.get_or_404(6) p_id = 3 filterd_resultr=Addproduct.query.filter_by(id=p_id).first() allresult = Addproduct.query.all() #Customer Login Logic form = CustomerLoginFrom() if form.validate_on_submit(): user = Register.query.filter_by(email=form.email.data).first() if user and bcrypt.check_password_hash(user.password, form.password.data): login_user(user) flash('You are login now!', 'success') next = request.args.get('next') return redirect(next or url_for('store')) flash('Incorrect email and password','danger') return redirect(url_for('store')) #Customer Register Logic form_R = CustomerRegisterForm() if form.validate_on_submit(): hash_password = bcrypt.generate_password_hash(form.password.data) register = Register(name=form.name.data, username=form.username.data, email=form.email.data,password=hash_password,country=form.country.data, city=form.city.data,contact=form.contact.data, address=form.address.data, zipcode=form.zipcode.data) db.session.add(register) flash(f'Welcome {form.name.data} Thank you for registering', 'success') db.session.commit() return redirect(url_for('store')) return render_template('tournaments.html' ,products=products, product=product, allresult=allresult, filterd_resultr=filterd_resultr, form=form, form_R=form_R )
def admin_register_custormer(): if 'email' not in session: flash(f'please login first', 'danger') return redirect(url_for('login')) form = CustomerRegisterForm() if form.validate_on_submit(): if Admin.query.filter_by(email=form.email.data).first(): flash(f'Email Used!', 'danger') return redirect(url_for('admin_register_custormer')) if Register.query.filter_by(email=form.email.data).first(): flash(f'Email Used!', 'danger') return redirect(url_for('admin_register_custormer')) if Register.query.filter_by(phone_number=form.phone_number.data).first(): flash(f'Phone Number Used!', 'danger') return redirect(url_for('admin_register_custormer')) try: hash_password = bcrypt.generate_password_hash(form.password.data).decode('utf8') register = Register(username=form.username.data, email=form.email.data, first_name=form.first_name.data, last_name=form.last_name.data, phone_number=form.phone_number.data, gender=form.gender.data, password=hash_password) db.session.add(register) flash(f'Register account " {form.first_name.data} {form.last_name.data} " success', 'success') db.session.commit() return redirect(url_for('admin_register_custormer')) except: flash(f'Error!', 'danger') return redirect(url_for('admin_register_custormer')) user = Admin.query.filter_by(email=session['email']).all() return render_template('admin/customer_register.html', form=form, user=user[0])
def get_Discount(): page = request.args.get('page',1, type=int) products = Addproduct.query.filter(Addproduct.stock > 0, Addproduct.discount).order_by(Addproduct.id.desc()).paginate(page=page, per_page=16) product = Addproduct.query.get_or_404(1) p_id = "1" filterd_resultr=Addproduct.query.filter_by(id=p_id).first() product = Addproduct.query.get_or_404(1) vi_product=filterd_resultr #Customer Login Logic form = CustomerLoginFrom() if form.validate_on_submit(): user = Register.query.filter_by(email=form.email.data).first() if user and bcrypt.check_password_hash(user.password, form.password.data): login_user(user) flash('You are login now!', 'success') next = request.args.get('next') return redirect(next or url_for('store')) flash('Incorrect email and password','danger') return redirect(url_for('store')) #Customer Register Logic form_R = CustomerRegisterForm() if form.validate_on_submit(): hash_password = bcrypt.generate_password_hash(form.password.data) register = Register(name=form.name.data, username=form.username.data, email=form.email.data,password=hash_password,country=form.country.data, city=form.city.data,contact=form.contact.data, address=form.address.data, zipcode=form.zipcode.data) db.session.add(register) flash(f'Welcome {form.name.data} Thank you for registering', 'success') db.session.commit() return redirect(url_for('store')) return render_template('store.html', title='layout', grandtotal=grandtotal(), products=products, brands=brands(), product=product, filterd_resultr=filterd_resultr, vi_product=vi_product, categories=categories(), form_R=form_R, form=form)
def register(): form = CustomerRegistrationForm(request.form) if request.method == 'POST': try: hash_password = bcrypt.generate_password_hash( form.password.data).decode('UTF-8') register = Register(name=form.name.data, username=form.username.data, email=form.email.data, password=hash_password, country=form.country.data, city=form.city.data, state=form.state.data, contact=form.contact.data, address=form.address.data, zipcode=form.zipcode.data) db.session.add(register) db.session.commit() flash(f'Welcome {form.name.data} Thank you for registering', 'success') return redirect(url_for('customer_login')) except Exception as e: flash(f'Username or email has already been taken', 'danger') print(e) return render_template('customer/register.html', form=form)
def create_model(self, form): model = self.model( form.username.data, form.password.data, form.admin.data ) form.populate_obj(model) model.password = bcrypt.generate_password_hash(form.password.data).decode('utf-8') self.session.add(model) self._on_model_change(form, model, True) self.session.commit()
def customer_register(): form = CustomerRegisterForm() if form.validate_on_submit(): hash_password = bcrypt.generate_password_hash(form.password.data) register = Register(name=form.name.data, username=form.username.data, email=form.email.data, password=hash_password, telephone=form.telephone.data, address=form.address.data, eircode=form.eircode.data) db.session.add(register) flash(f'Welcome {form.name.data}, thank you registering', 'success') db.session.commit() return redirect(url_for('customerLogin')) return render_template('customer/register.html', form=form)
def register(): form = RegistrationForm() if form.validate_on_submit(): hash_password = bcrypt.generate_password_hash(form.password.data) user = User(name=form.name.data,username=form.username.data, email=form.email.data, password=hash_password) db.session.add(user) flash(f'welcome {form.name.data} Thanks for registering','success') db.session.commit() return redirect(url_for('login')) return render_template('admin/register.html',title='Register user', form=form)
def customer_register(): form = CustomerRegisterForm() if form.validate_on_submit(): hash_password = bcrypt.generate_password_hash(form.password.data) register = Register(name=form.name.data, username=form.username.data, email=form.email.data,password=hash_password,country=form.country.data, city=form.city.data,contact=form.contact.data, address=form.address.data, zipcode=form.zipcode.data) db.session.add(register) flash(f'Welcome {form.name.data} Thank you for registering', 'success') db.session.commit() return redirect(url_for('login')) return render_template('customer/register.html', form=form)
def update_model(self, form, model): form.populate_obj(model) if form.new_password.data: if form.new_password.data != form.confirm.data: flash('Passwords must match') return model.password = bcrypt.generate_password_hash(form.new_password.data).decode('utf-8') self.session.add(model) self._on_model_change(form, model, False) self.session.commit()
def register(): form = RegistrationForm(request.form) if request.method == 'POST' and form.validate(): hash_password = bcrypt.generate_password_hash(form.password.data) user = User(name=form.name.data, username=form.username.data, email=form.email.data, password=hash_password) db.session.add(user) db.session.commit() flash(f'Welcome, {form.name.data}! Thanks you for registering', 'success') return redirect(url_for('admin')) return render_template('admin/register.html', form=form, title='Registration')
def register(): form = RegistrationForm(request.form) if request.method == 'POST' and form.validate(): hash_password = bcrypt.generate_password_hash(form.password.data) user = User(username=form.username.data, email=form.email.data, password=hash_password) db.session.add(user) db.session.commit() flash('Hoe ' + str(form.username.data) + ' kullia imet') return redirect(url_for('admin')) return render_template('admin/register.html', title="REGUSER", form=form)
def register(): form = RegistrationForm(request.form) if request.method == 'POST' and form.validate(): hash_password = bcrypt.generate_password_hash(form.password.data) user = User(name=form.name.data, username=form.username.data, email=form.email.data, password=hash_password) db.session.add(user) db.session.commit() flash(f'Bienvenido! {form.name.data} Gracias por regristrarte', 'success') return redirect(url_for('login')) return render_template("admin/register.html", form=form, title="Registro de usuario")
def customer_register(): form = CustomerRegisterForm(request.form) if request.method == 'POST': hash_password = bcrypt.generate_password_hash(form.password.data) register = Register(name=form.name.data, username=form.username.data, email=form.email.data, password=hash_password, country=form.country.data, state=form.state.data, city=form.city.data, address=form.address.data, zipcode=form.zipcode.data, contact=form.contact.data) # Ignorar error. Por alguna razón da el metodo como inaccesible. Pero funciona. db.session.add(register) flash(f"Bienvenido{form.name.data} Gracias por registrarte", 'success') db.session.commit() return redirect(url_for('login')) return render_template('customer/register.html', form=form)
def register(): if 'email' not in session: flash(f'please login first', 'danger') return redirect(url_for('login')) form = RegistrationForm(request.form) if request.method == 'POST' and form.validate(): hash_password = bcrypt.generate_password_hash(form.password.data).decode('utf8') user = Admin(name=form.name.data, username=form.username.data, email=form.email.data, password=hash_password) db.session.add(user) db.session.commit() flash(f' Wellcom {form.name.data} Thanks for registering', 'success') return redirect(url_for('register')) user = Admin.query.filter_by(email=session['email']).all() return render_template('admin/admin_register.html', form=form, title='Registration page', user=user[0])
def signup(): if current_user.is_authenticated: return redirect(url_for('index')) form = RegistrationForm(request.form) if request.method == 'POST' and form.validate(): hash_password = bcrypt.generate_password_hash(form.password.data) user = User(username=form.username.data, email=form.email.data, password=hash_password) db.session.add(user) db.session.commit() flash(f'Thanks {form.username.data} for registering') return redirect(url_for('login')) return render_template('signup.html', form=form)
def register(): form = RegistrationForm(request.form) if request.method == 'POST' and form.validate(): hash_password = bcrypt.generate_password_hash(form.password.data) user = User(name=form.name.data, username=form.username.data, email=form.email.data, password=hash_password) db.session.add(user) flash('Thanks for registering') return redirect(url_for('home')) return render_template('admin/register.html', form=form, title="Registeration page")
def register(): form = RegistrationForm() if form.validate_on_submit(): hash_password = bcrypt.generate_password_hash(form.password.data) user = User(name=form.name.data, username=form.username.data, email=form.email.data, password=hash_password) db.session.add(user) flash(f'Добро пожаловать {form.name.data} !', 'success') db.session.commit() return redirect(url_for('login')) return render_template('admin/register.html', title='Регистрация пользователся', form=form)
def customer_register(): formR = CustomerRegisterForm() if formR.validate_on_submit(): hash_password = bcrypt.generate_password_hash(formR.password.data) register = Register(FirstName=formR.FirstName.data, SecondName=formR.SecondName.data, username=formR.username.data, email=formR.email.data, password=hash_password) db.session.add(register) flash(f'Welcome {formR.username.data} Thank you for registering', 'success') db.session.commit() return redirect(url_for('customerLogin')) return render_template('customer/register.html', formR=formR)
def register(): form = RegistrationForm(request.form) if request.method == 'POST' and form.validate(): hash_password = bcrypt.generate_password_hash(form.password.data) user = User(username=form.username.data, name=form.name.data, email=form.email.data, password=hash_password) db.session.add(user) db.session.commit() flash(f'{form.name.data} Gracias Por Registrarte', 'success') return redirect(url_for('login')) return render_template('admin/register.html', form=form, title='Pagina de registro')
def customer_registration(): form = CustomerRegistrationForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user = Customer(name = form.name.data, username = form.username.data, email = form.email.data, password= hashed_password,country = form.country.data,\ state = form.state.data,city = form.city.data,address = form.address.data,pin = form.pincode.data,contact = form.contact.data) db.session.add(user) db.session.commit() flash(f'Thank you for regestering! You are now able to log in!', 'success') return redirect(url_for('customer_login')) return render_template('customer/register.html', title='Register', form=form)
def register(): form = RegistrationForm(request.form) if request.method == "POST" and form.validate(): hash_password = bcrypt.generate_password_hash(form.password.data) user = User( name=form.name.data, username=form.username.data, email=form.email.data, password=hash_password, ) db.session.add(user) db.session.commit() flash(f"Welcome {form.name.data},Thank You for registering", "success") return redirect(url_for("login")) return render_template("admin/register.html", form=form, title="Register")
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 register(): from shop.admin.models import Admin form = RegistrationForm(request.form) if request.method == 'POST' and form.validate(): hash_password = bcrypt.generate_password_hash( password=form.password.data) admin = Admin(name=form.name.data, username=form.username.data, email=form.email.data, password=hash_password.decode('ascii')) db.session.add(admin) db.session.commit() flash(f'Welcome {form.name.data} Thanks for registering', 'success') return redirect(url_for('management.admin')) return render_template('admin/register.html', form=form, title="Registration Page")
def register(): form = RegistrationForm(request.form) if request.method == 'POST' and form.validate(): hash_password = bcrypt.generate_password_hash(form.password.data) user = User(name=form.name.data, username=form.username.data, email=form.email.data, password=hash_password) db.session.add(user) db.session.commit() flash( f'Welcome {form.name.data}. Terimakasih sudah melakukan register', 'success') return redirect(url_for('login')) return render_template('admin/register.html', form=form, title="Registeration page")
def changes_password(): if 'email' not in session: flash(f'please login first', 'danger') return redirect(url_for('login')) user = Admin.query.filter_by(email=session['email']) detail_password_admin = Admin.query.get_or_404(user[0].id) old_password = request.form.get('oldpassword') new_password = request.form.get('newpassword') if request.method == "POST": if not bcrypt.check_password_hash(detail_password_admin.password, old_password.encode('utf8')): flash(f'Old passwords do not match!', 'danger') return redirect(url_for('changes_password')) detail_password_admin.password = bcrypt.generate_password_hash(new_password).decode('utf8') flash(f'Change Password Complete!', 'success') db.session.commit() return redirect(url_for('changes_password')) return render_template('admin/change_password.html', title='Change Password', user=user[0])
def account(): form = UpdateAccountForm() if form.validate_on_submit(): current_user.username = form.username.data current_user.email = form.email.data if bcrypt.check_password_hash(current_user.password, form.old_pass.data): hashed_password = bcrypt.generate_password_hash( form.new_pass.data).decode('utf-8') current_user.password = hashed_password db.session.commit() flash('Your account has been updated!', 'success') return redirect(url_for('account')) elif request.method == 'GET': form.username.data = current_user.username form.email.data = current_user.email return render_template('account.html', title='Account', form=form)
def customer_register(): form = CustomerForm() if form.validate_on_submit(): hash_password = bcrypt.generate_password_hash(form.password.data) register = Register(name=form.name.data, username=form.username.data, email=form.email.data, password=hash_password, phone=form.phone.data, institution=form.institution.data, major=form.major.data, semester=form.semester.data, birthday=form.birthday.data) db.session.add(register) db.session.commit() flash(f'Welcome, {form.name.data} Thanks for registering', 'success') return redirect(url_for('customer_login')) return render_template('customer/register.html', form=form)
def register_customer(): form = CustomerRegistrationForm() if form.validate_on_submit(): hash_password = bcrypt.generate_password_hash(form.password.data) register = RegisterModel(name=form.name.data, username=form.username.data, email=form.email.data, password=hash_password, country=form.country.data, state=form.state.data, city=form.city.data, address=form.address.data, contact=form.contact.data) db.session.add(register) db.session.commit() flash(f"Welcome:{form.name.data} Thank Your for Registering", 'success') return redirect(url_for('login')) return render_template('customers/register.html', form=form)
def reset_by_token(token): if current_user.is_authenticated: return redirect(url_for('home')) user = Customer.verify_token(token) if user is None: flash(f'It is an invalid or expired token', 'error') return redirect(url_for('reset_request')) form = ResetPasswordForm() if form.validate_on_submit(): hashed_password = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user.password = hashed_password db.session.commit() flash(f'Your password has been changed. You are now able to log in!', 'success') return redirect(url_for('customer_login')) return render_template('customer/reset_by_token.html', title='Reset Password', 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 = Users(username=form.username.data, email=form.email.data, address=form.address.data, date_of_birth=form.date_of_birth.data, password=hashed_password) db.session.add(user) db.session.commit() flash("Your account has been created!", 'success') return redirect(url_for('login')) return render_template("customer/register.html", title="Register", form=form)