Exemple #1
0
def seller_login():
    if request.method == 'POST':
        email = request.form.get("email")
        password1 = request.form.get("password")
        seller = Register_seller.query.filter_by(email = email ).first()
        
        # form.email.data = ""
        if seller and bcrypt.check_password_hash(seller.password,password1):
            login_user(seller)
            return redirect(url_for('shops'))
        elif seller is None:
            flash(f"You haven't registered yet! Register first!")
              
        else:
            flash(f'Login Unsuccessful. Please check email or password','danger')     
            return redirect(url_for('seller_login')) 

    return render_template('sellers/login.html')    
Exemple #2
0
def user_login():
    if request.method == 'POST':
        email1 = request.form.get("email1")
        password1 = request.form.get("password1")
        customer = Register_user.query.filter_by(email = email1).first()
        
        # form.email.data = ""
        if customer and bcrypt.check_password_hash(customer.password,password1):
            # return redirect(url_for('shops', id = seller.id))
            # return redirect(url_for('main', id = customer.id))
            login_user(customer)
            # print(customer.name)
            return redirect(url_for('main',id=customer.id))

        elif customer is None:
            flash(f"You haven't registered yet! Register first!")
              
        else:
            flash(f'Login Unsuccessful. Please check email or password','danger')     
            return redirect(url_for('user_login')) 

    return render_template("customers/login_user.html")