def register(): form = LoginForm() if form.validate_on_submit(): if form.password.data != form.password_again.data: return render_template('login.html', form=form, message="Пароли не совпадают") db_sess = db_session.create_session() if db_sess.query(User).filter(User.email == form.email.data).first(): return render_template('login.html', form=form, message="Такой пользователь уже есть") user = User( surname=form.surname.data, name=form.name.data, age=form.age.data, position=form.position.data, speciality=form.speciality.data, email=form.email.data, ) user.set_password(form.password.data) db_sess.add(user) db_sess.commit() return render_template('success.html') return render_template('login.html', form=form)
def login(): form = LoginForm() if form.validate_on_submit(): session = create_session() user = session.query(User).filter(User.email == form.email.data).first() if user and user.check_password(form.password.data): login_user(user, remember=form.remember_me.data) return redirect("/") return render_template('login.html', message="Неправильный логин или пароль", form=form) return render_template('login.html', title='Авторизация', form=form)
def login(): form = LoginForm() if form.validate_on_submit(): session = db_session.create_session() user = session.query(User).filter(User.email == form.email.data).first() if user and user.check_password(form.password.data): login_user(user, remember=form.remember_me.data) return redirect("/create_cart") return render_template('login.html', message="Wrong email or password", form=form) return render_template('login.html', title='Authorization', form=form)
def login(): form = LoginForm() if form.validate_on_submit(): session = db_session.create_session() player = session.query(Player).filter( Player.email == form.email.data).first() if player and player.check_password(form.password.data): login_user(player, remember=form.remember_me.data) player.online = True session.commit() return redirect(f"/{player.hashed_id}") return render_template('login.html', message="Неправильный логин или пароль", form=form) return render_template('login.html', title='Авторизация', form=form)