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


Python User.checkPass方法代码示例

本文整理汇总了Python中users.User.checkPass方法的典型用法代码示例。如果您正苦于以下问题:Python User.checkPass方法的具体用法?Python User.checkPass怎么用?Python User.checkPass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在users.User的用法示例。


在下文中一共展示了User.checkPass方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_check_password

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import checkPass [as 别名]
 def test_check_password(self):
     # Ensure given password is correct after unhashing
     user = User()
     user.config = app.config
     user = user.get('username', '[email protected]', g.rdb_conn)
     self.assertTrue(user.checkPass('password456', g.rdb_conn))
     self.assertFalse(user.checkPass('wrong!', g.rdb_conn))
开发者ID:Runbook,项目名称:runbook,代码行数:9,代码来源:test_user.py

示例2: login_page

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import checkPass [as 别名]
def login_page():
    ''' User login page: This is a basic login page'''
    data = {
        'active': 'login',
        'loggedin': False
    }

    # Define and Validate the form
    form = LoginForm(request.form)
    if request.method == "POST":
        if form.validate():
            email = form.email.data
            password = form.password.data

            # Start user definition
            user = User()
            if user.get('username', email, g.rdb_conn):
                result = user.checkPass(password, g.rdb_conn)
                if result is True:
                    data['loggedin'] = True
                    data['msg'] = 'You are logged in'
                    data['error'] = False
                    print("/login - User login successful")
                    # Start building response
                    resp = make_response(
                        redirect(url_for('member.dashboard_page')))
                    cdata = cookies.genCdata(
                        user.uid, app.config['SECRET_KEY'])
                    timeout = int(time.time()) + \
                        int(app.config['COOKIE_TIMEOUT'])
                    # Set cookie as securely as possible
                    resp.set_cookie(
                        'loggedin', cdata, expires=timeout, httponly=True)
                    print("Setting cookie")
                    return resp
                else:
                    data['msg'] = 'Password does not seem valid'
                    data['error'] = True
                    print("/login - User login error: wrong password")
            else:
                data['msg'] = 'Uhh... User not found'
                print("/login - User login error: invalid user")
                data['error'] = True
        else:
            data['msg'] = 'Form is not valid'
            print("/login - User login error: invalid form")
            data['error'] = True

    # Return Login Page
    page = render_template('user/login.html', data=data, form=form)
    return page
开发者ID:bshyong,项目名称:cloudroutes-service,代码行数:53,代码来源:views.py

示例3: userpref_page

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import checkPass [as 别名]
def userpref_page():
    '''
    Dashbaord User Preferences:
    This will allow a user to change user preferences, i.e. Password
    '''
    verify = verifyLogin(
        app.config['SECRET_KEY'], app.config['COOKIE_TIMEOUT'], request.cookies)
    if verify:
        user = User()
        user.config = app.config
        user.get('uid', verify, g.rdb_conn)
        data = startData(user)
        data['active'] = 'dashboard'
        if user.status != "active":
            data['url'] = '/dashboard/mod-subscription'
            tmpl = 'member/mod-subscription.html'
        else:
            # Start processing the change password form
            form = ChangePassForm(request.form)
            if request.method == 'POST':
                if form.validate():
                    result = user.checkPass(form.old_password.data, g.rdb_conn)
                    if result:
                        update = user.setPass(form.password.data, g.rdb_conn)
                        if update:
                            print("/dashboard/user-preferences - Password changed")
                            flash('Password successfully changed.', 'success')
                        else:
                            print("/dashboard/user-preferences - \
                                  Password change failed")
                            flash('Password change was unsuccessful.', 'danger')
                    else:
                        print("/login - User change password error: wrong old password")
                        flash('Old password does not seem valid.', 'danger')
            data['url'] = '/dashboard/user-preferences'
            tmpl = 'member/user-preferences.html'
        page = render_template(tmpl, data=data, form=form)
        return page
    else:
        flash('Please Login.', 'warning')
        return redirect(url_for('user.login_page'))
开发者ID:madflojo,项目名称:cloudroutes-service,代码行数:43,代码来源:views.py

示例4: login_page

# 需要导入模块: from users import User [as 别名]
# 或者: from users.User import checkPass [as 别名]
def login_page():
    """ User login page: This is a basic login page"""
    data = {"active": "login", "loggedin": False}

    # Define and Validate the form
    form = LoginForm(request.form)
    if request.method == "POST":
        if form.validate():
            email = form.email.data
            password = form.password.data

            # Start user definition
            user = User()
            user.config = app.config
            if user.get("username", email, g.rdb_conn):
                result = user.checkPass(password, g.rdb_conn)
                if result is True:
                    data["loggedin"] = True
                    print("/login - User login successful")
                    flash("You are logged in.", "success")
                    # Start building response
                    resp = make_response(redirect(url_for("member.dashboard_page")))
                    cdata = cookies.genCdata(user.uid, app.config["SECRET_KEY"])
                    timeout = int(time.time()) + int(app.config["COOKIE_TIMEOUT"])
                    # Set cookie as securely as possible
                    resp.set_cookie("loggedin", cdata, expires=timeout, httponly=True)
                    print("Setting cookie")
                    return resp
                else:
                    print("/login - User login error: wrong password")
                    flash("Password does not seem valid.", "danger")
            else:
                print("/login - User login error: invalid user")
                flash("Uhh... User not found.", "danger")
        else:
            print("/login - User login error: invalid form")
            flash("Form is not valid.", "danger")

    # Return Login Page
    return render_template("user/login.html", data=data, form=form)
开发者ID:pathcl,项目名称:runbook,代码行数:42,代码来源:views.py


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