本文整理汇总了Python中app.forms.LoginForm.errors["password"]方法的典型用法代码示例。如果您正苦于以下问题:Python LoginForm.errors["password"]方法的具体用法?Python LoginForm.errors["password"]怎么用?Python LoginForm.errors["password"]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.forms.LoginForm
的用法示例。
在下文中一共展示了LoginForm.errors["password"]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: login
# 需要导入模块: from app.forms import LoginForm [as 别名]
# 或者: from app.forms.LoginForm import errors["password"] [as 别名]
def login():
""" Starting page with login.
For Log in: take email, password from user and check if credentials exist in the database
by checking if email is in the users table. If email in table, redirect to the children overview.
If not: redirect to sign up page. WTForms validates the form.
"""
form = LoginForm(request.form)
next_url = request.args.get('next', '/overview')
if request.method == 'POST' and form.validate(): # Process form if route gets POST request from /index
next_url = request.form.get('next', '/overview')
user = User.query.filter_by(email=form.data['email']).first()
if user and user.check_password(form.data['password']):
login_user(user)
if not auth.is_safe_url(next_url):
return abort(400)
app.logger.debug(next_url)
return redirect(next_url or '/overview')
if not user:
return redirect('/signup')
# Show error message ('Incorrect password.')
form.errors["password"] = ["Incorrect password"]
status_code = 400 if form.errors else 200
return render_template("login.html", form=form, next=next_url), status_code