本文整理汇总了Python中model.User.get_user_by_email方法的典型用法代码示例。如果您正苦于以下问题:Python User.get_user_by_email方法的具体用法?Python User.get_user_by_email怎么用?Python User.get_user_by_email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.User
的用法示例。
在下文中一共展示了User.get_user_by_email方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: confirm_user_login
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_user_by_email [as 别名]
def confirm_user_login():
"""Confirm user account information is correct."""
user_email = request.form.get("email")
user_password = request.form.get("password")
try:
# checks if user exists
user = User.get_user_by_email(user_email)
# get pw from db and compare it to user input
hash = user.password
password_check = sha256_crypt.verify(user_password, hash)
# if everything works, log user in and create a cart
if password_check:
userid = user.user_id
session['User'] = userid
if 'Cart' not in session:
new_cart = Cart.create_new_cart(userid)
session['Cart'] = new_cart.cart_id
return jsonify({"confirmed_user": True, "user_id": userid})
else:
raise Exception
except Exception:
return jsonify({"confirmed_user": False})
示例2: confirm_new_user
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_user_by_email [as 别名]
def confirm_new_user():
"""Creates new user"""
# flash=[]
# It gets email and password from the POST param
user_email = request.form.get("email")
user_password = request.form.get("password")
name = request.form.get("name")
#It checks if user already exists or email is invalid
confirmed_user = User.get_user_by_email(user_email)
# is_valid = validate_email(user_email,verify=True)
# EMAIL_RE.search(user_email)
if True:
if not confirmed_user:
User.create_user_by_email_password(user_email, user_password, name)
flash("You successfully created an account!")
return redirect('/')
else:
flash("You already have an account")
return render_template('error.html',url='homepage.html')
else:
flash("The email that you entered is invalid")
# return render_template('error.html',url='homepage.html')
return render_template('error.html',url='homepage.html')
示例3: confirm_new_user
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_user_by_email [as 别名]
def confirm_new_user():
"""Create new user"""
user_email = request.form.get("email")
user_password = request.form.get("password")
confirmed_user = User.get_user_by_email(user_email)
if not confirmed_user:
User.create_user_by_email_password(user_email, user_password)
flash("You successfully created an account!")
else:
flash("You already have an account")
return redirect("/")
示例4: confirm_new_account
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_user_by_email [as 别名]
def confirm_new_account():
"""Confirm new account"""
user_email = request.form.get("email")
user_password = request.form.get("password1")
user_phone = request.form.get("phone")
confirmed_user = User.get_user_by_email(user_email)
if not confirmed_user:
hash = sha256_crypt.encrypt(user_password)
User.create_new_user(user_email, hash, user_phone)
flash("You successfully created an account! Please log in to get started.", "create_account")
else:
flash("You already have an account. Please sign in.", "account_already")
return redirect("/")
示例5: login_process
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_user_by_email [as 别名]
def login_process():
"""Process login."""
# Get form variables
email = request.form["email"]
password = request.form["password"]
user = User.get_user_by_email(email)
# user = User.query.filter_by(email=email).first()
if not user:
flash("No such user")
return redirect("/login")
if user.password != password:
flash("Incorrect password")
return redirect("/login")
session["user_id"] = user.user_id
flash("Logged in")
return redirect("/users/%s" % user.user_id)
示例6: get
# 需要导入模块: from model import User [as 别名]
# 或者: from model.User import get_user_by_email [as 别名]
def get(self, email):
"""Get a user's userid given their email address."""
user = User.get_user_by_email(email)
return {user.user_id: user.email}