本文整理汇总了Python中accounts.models.Account.find_by_email方法的典型用法代码示例。如果您正苦于以下问题:Python Account.find_by_email方法的具体用法?Python Account.find_by_email怎么用?Python Account.find_by_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accounts.models.Account
的用法示例。
在下文中一共展示了Account.find_by_email方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: login
# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import find_by_email [as 别名]
def login():
if "email" in session:
account = Account.find_by_email(session["email"])
if account:
return redirect(url_for("instances.list"))
return render_template("auth/login.html", form=AuthenticationForm())
示例2: authenticate
# 需要导入模块: from accounts.models import Account [as 别名]
# 或者: from accounts.models.Account import find_by_email [as 别名]
def authenticate():
form = AuthenticationForm(request.form)
if not form.validate():
return render_template("auth/login.html", form=form)
account = Account.find_by_email(form.email.data)
if not account:
form.email.errors = ["Invalid email or password."]
elif not account.check_passwd(form.password.data):
form.email.errors = ["Invalid email or password."]
if len(form.email.errors) > 0:
form.password.data = None
return render_template("auth/login.html", form=form)
session["email"] = form.email.data
return redirect(url_for("instances.list"))