def sign_in(): if request.method == 'POST': action = request.form['submit'] if action == "Регистрация": return render_template('registration.html') login = request.form['login'] password = request.form['password'] p_hash = DbUtils.get_user_password(login) if p_hash is not None: if check_password_hash(DbUtils.get_user_password(login), password): tmp = DbUtils.select_user_full(login) app.config['USER'] = User(tmp[0][0], tmp[0][1], tmp[0][2], tmp[0][3], tmp[0][4]) products = Utils.get_prod_units() return render_template('buy_prod_units.html', products=products, len_p=len(products), login=app.config['USER'].login, type=app.config['USER'].type) else: return render_template('index.html', messege="Неправильный логин или пароль") else: return render_template('index.html', messege="Неправильный логин или пароль") else: return redirect(url_for('index.html')) return render_template('index.html')
def registration(): if request.method == 'POST': DbUtils.insert_user(request.form['login'], request.form['password'], request.form['email'], request.form['user_type'], request.form['full_name']) tmp = DbUtils.select_user_full(request.form['login']) app.config['USER'] = User(tmp[0][0], tmp[0][1], tmp[0][2], tmp[0][3], tmp[0][4]) products = Utils.get_prod_units() return render_template('buy_prod_units.html', products=products, len_p=len(products), login=app.config['USER'].login) return render_template('registration.html')