def login(): if session.get('email'): return redirect('order') else: formLog = loginForm() if formLog.validate_on_submit(): customer_selected = CompanyCustomer.query.filter_by(email=formLog.email.data.upper()).first() if CompanyCustomer.query.filter_by(email=formLog.email.data.upper()).first(): if bcrypt.check_password_hash(customer_selected.password, formLog.password.data): session['email'] = customer_selected.email.upper() session['id_user'] = customer_selected.name_company.upper() session['type'] = 'COMPANY' return redirect('register_company_employee') else: error = 'ERROR: username or password should be incorrect. Please Try again' return redirect('login') elif PrivateCustomer.query.filter_by(email=formLog.email.data.upper()).first(): customer_selected = PrivateCustomer.query.filter_by(email=formLog.email.data.upper()).first() if bcrypt.check_password_hash(customer_selected.password, formLog.password.data): session['email'] = customer_selected.email.upper() session['id_user'] = customer_selected.name.upper() session['username'] = customer_selected.username.upper() session['type'] = 'PRIVATE' return redirect('order') else: error = 'ERROR: username or password should be incorrect. Please Try again' return redirect('login') return render_template('login.html', formLog=formLog)
def login(): from form import loginForm from toDB import get_user_list, get_user_passwd from hashlib import md5 form = loginForm() if form.validate_on_submit(): phone = form.phone.data user_list = get_user_list() if phone not in user_list: flash('用户不存在') print( time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + '用户' + phone + '尝试登陆:错误的用户名') else: passwd = md5(form.password.data.encode()).hexdigest() ck_passwd = get_user_passwd(phone) if passwd == ck_passwd: auto_login = form.remember_me.data user = User() user.id = phone login_user(user, auto_login) print( time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + '用户' + phone + '登陆成功') return redirect(url_for('index')) print( time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + '用户' + phone + '尝试登陆:密码错误') flash('密码错误') return render_template('login.html', Form=form)
def login(): form = loginForm(request.form) if session.get("userdata") is None: session["userdata"] = [] if request.method == "POST" and form.validate(): login_user = request.form["username"] password = request.form["password"] cur = mysql.connection.cursor() sql = ("SELECT * FROM user WHERE username='******'") cur.execute(sql) data = cur.fetchall() if data: for pass_in_db in data: if pass_in_db[3] == password: session["userdata"].append(login_user) session["userdata"].append(password) userdata = session["userdata"] return redirect(url_for('home')) else: flash("Error: Username and password combination is wrong!!") else: flash("Error: There is no account for this username!!") else: userdata = session["userdata"] return redirect(url_for('home')) return render_template("login.html", form=form)
def login(): if session.get('username'): return redirect('profile') else: formRed = loginForm() if formRed.validate_on_submit(): customer_selected = PrivateCustomer.query.filter_by( username=formRed.username.data).first() if bcrypt.check_password_hash(customer_selected.password, formRed.password.data): session['username'] = customer_selected.username return redirect('home') return render_template('login.html', formReg=formRed)
def login(): login_form = loginForm() if login_form.validate_on_submit(): user_info = User.query.filter_by( username=login_form.username.data).first() if user_info and bcrypt.check_password_hash(user_info.password, login_form.password.data): session['user_id'] = user_info.id session['name'] = user_info.name session['email'] = user_info.username session['role_id'] = user_info.role_id return redirect('dashboard') return render_template('login.html', login_form=login_form)
def login_page(): form = loginForm() if session["user_id"] != None: flash('logout first', category='primary') return redirect('/') if form.validate_on_submit(): username = form.username.data password = form.password.data user = User.authenticate(username, password) if user: session['user_id'] = user.username return redirect(f'/user/{user.username}') else: flash(f'Wrong username or Password') return render_template('login.html', form=form) else: return render_template('login.html', form=form)
def loginpage(): form = loginForm() return render_template("login.html", title="Login", form=form)
def login(): form = loginForm() return render_template('login.html', title='Login', form=form)