def login(): form = LoginForm() if form.is_submitted(): user = User.query.filter_by(username=form.username.data).first() if user: if check_password_hash(user.password, form.password.data): login_user(user) return "Login successful!" else: return "Incorrect password!" else: return "Invalid username or password!" return render_template('login.html', form=form)
def login_page(): form = LoginForm() form.departName.choices = [(org.id, org.name) for org in OrgStructure.query.filter_by(type=1).all()] if form.is_submitted(): externalsID = get_externals() hirurgList = get_hirurg_list(form.departName.data) anesteziologList = get_anesteziolog_list() importData = get_oper_list(form.operDate.data, form.departName.data) depNameTitle = {index: value for index, value in form.departName.choices}.get(int(form.departName.data)) return render_template('add_client.html', departName=depNameTitle, operDate=form.operDate.data.strftime('%d.%m.%Y'), externals=externalsID, hirurgs=hirurgList, anesteziologList=anesteziologList, dataSet=importData, depID=form.departName.data, opDate=form.operDate.data) return render_template('login.html', logForm=form)
def login(): """For GET requests, display the login form. For POSTS, login the current user by processing the form.""" form = LoginForm(csrf_enabled=True) if form.is_submitted(): if form.validate(): user = User.query.get(form.username.data) if user and bcrypt.check_password_hash(user.password, form.password.data): user.authenticated = True db.session.add(user) db.session.commit() login_user(user, remember=True) return redirect("/appConfig") else: return render_template("login.html", form=form, message="Invalid Login!!!") else: return render_template("login.html", form=form, message="Invalid Login!!!") else: return render_template("login.html", form=form)