当前位置: 首页>>代码示例>>Python>>正文


Python User.get_user_by_email方法代码示例

本文整理汇总了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})
开发者ID:jturn130,项目名称:eatable,代码行数:33,代码来源:server.py

示例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')
开发者ID:Francydijesi,项目名称:hackbright_project,代码行数:34,代码来源:server.py

示例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("/")
开发者ID:jturn130,项目名称:ratings,代码行数:17,代码来源:server.py

示例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("/")
开发者ID:jturn130,项目名称:eatable,代码行数:19,代码来源:server.py

示例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)
开发者ID:magicericat,项目名称:lamastate,代码行数:25,代码来源:server.py

示例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}
开发者ID:jturn130,项目名称:eatable,代码行数:8,代码来源:server.py


注:本文中的model.User.get_user_by_email方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。