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


Python security.check_password_hash方法代码示例

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


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

示例1: home

# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import check_password_hash [as 别名]
def home():
    if current_user.is_authenticated:
        return redirect(url_for("portfolio.portfolio_main"))
    else:
        form = LoginForm()
        if form.validate_on_submit():
            user = User.query.filter_by(email=form.email.data).first()
            if user and check_password_hash(user.password, form.password.data):
                login_user(user, remember=form.remember.data)
                # The get method below is actually very helpful
                # it returns None if empty. Better than using [] for a dictionary.
                next_page = request.args.get("next")  # get the original page
                if next_page:
                    return redirect(next_page)
                else:
                    return redirect(url_for("main.home"))
            else:
                flash("Login failed. Please check e-mail and password",
                      "danger")

        return render_template("index.html", title="Login", form=form) 
开发者ID:pxsocs,项目名称:thewarden,代码行数:23,代码来源:routes.py

示例2: login

# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import check_password_hash [as 别名]
def login():
    if current_user.is_authenticated:
        return redirect(url_for("main.home"))
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user and check_password_hash(user.password, form.password.data):
            login_user(user, remember=form.remember.data)
            # The get method below is actually very helpful
            # it returns None if empty. Better than using [] for a dictionary.
            next_page = request.args.get("next")  # get the original page
            if next_page:
                return redirect(next_page)
            else:
                return redirect(url_for("main.home"))
        else:
            flash("Login failed. Please check e-mail and password", "danger")

    return render_template("login.html", title="Login", form=form) 
开发者ID:pxsocs,项目名称:thewarden,代码行数:21,代码来源:routes.py

示例3: load_user_from_auth_header

# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import check_password_hash [as 别名]
def load_user_from_auth_header(header_val):
    if header_val.startswith('Basic '):
        header_val = header_val.replace('Basic ', '', 1)
    basic_username = basic_password = ''
    try:
        header_val = base64.b64decode(header_val).decode('utf-8')
        basic_username = header_val.split(':')[0]
        basic_password = header_val.split(':')[1]
    except (TypeError, UnicodeDecodeError, binascii.Error):
        pass
    user = _fetch_user_by_name(basic_username)
    if user and config.config_login_type == constants.LOGIN_LDAP and services.ldap:
        if services.ldap.bind_user(str(user.password), basic_password):
            return user
    if user and check_password_hash(str(user.password), basic_password):
        return user
    return 
开发者ID:janeczku,项目名称:calibre-web,代码行数:19,代码来源:web.py

示例4: login

# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import check_password_hash [as 别名]
def login():
    data = request_data()
    account = Account.by_name(data.get('login'))
    if account is not None:
        if check_password_hash(account.password, data.get('password')):
            login_user(account, remember=True)
            return jsonify({
                'status': 'ok',
                'message': _("Welcome back, %(name)s!", name=account.name)
            })
    return jsonify({
        'status': 'error',
        'errors': {
            'password': _("Incorrect user name or password!")
        }
    }, status=400) 
开发者ID:openspending,项目名称:spendb,代码行数:18,代码来源:session.py

示例5: check

# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import check_password_hash [as 别名]
def check(self, uid=None, passwd=None):
        """:func:`burpui.misc.auth.basic.BasicLoader.check` verifies if the
        given password matches the given user settings.

        :param uid: User to authenticate
        :type uid: str

        :param passwd: Password
        :type passwd: str

        :returns: True if there is a match, otherwise False
        """
        self.load_users()
        if uid in self.users:
            if self.users[uid]['salted']:
                return check_password_hash(self.users[uid]['pwd'], passwd)
            else:
                return self.users[uid]['pwd'] == passwd
        return False 
开发者ID:ziirish,项目名称:burp-ui,代码行数:21,代码来源:basic.py

示例6: verifyPassword

# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import check_password_hash [as 别名]
def verifyPassword(self, password):
        userObj = None
        if self.id is None:
            return(False)

        if password is None:
            return(False)

        else:
            userObj = self.getUserInfo()
            if check_password_hash(userObj.password, password):
                self.email = userObj.email
                self.group_list = userObj.group_list
                self.role_list = userObj.role_list
                self.business_system_list = userObj.business_system_list
                return(True)

    ## getUserInfo func 
开发者ID:kylechenoO,项目名称:AIOPS_PLATFORM,代码行数:20,代码来源:User.py

示例7: login

# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import check_password_hash [as 别名]
def login():
    form = LoginForm()

    if form.validate_on_submit():
        user = User.query.filter_by(username=form.username.data).first()
        if user:
            if check_password_hash(user.password_hash, form.password.data):
                print(form.remember.data)
                login_user(user, remember=form.remember.data)
                if 'next' in session:
                    next = session['next']
                    if is_safe_url(next):
                        return redirect(next)
                return redirect(url_for('antminer.miners'))
        flash("[ERROR] Invalid username or password", "error")
        return render_template('user/login.html', form=form)

    if current_user.is_authenticated:
        return redirect(url_for('antminer.miners'))

    return render_template('user/login.html', form=form) 
开发者ID:anselal,项目名称:antminer-monitor,代码行数:23,代码来源:views.py

示例8: __edit

# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import check_password_hash [as 别名]
def __edit(self, args):

        result = {"status": "success", "msg": "用户信息修改成功"}
        user_path = self.app.config["AUTO_HOME"] + "/users/" + args["username"]
        if exists_path(user_path):
            config = json.load(codecs.open(user_path + '/config.json', 'r', 'utf-8'))
            if check_password_hash(config["passwordHash"], args["password"]):
                config["passwordHash"] = generate_password_hash(args["new_password"])
                config["fullname"] = args["fullname"]
                config["email"] = args["email"]
                json.dump(config, codecs.open(user_path + '/config.json', 'w', 'utf-8'))
            else:
                result["status"] = "fail"
                result["msg"] = "原始密码错误"
        else:
            result["status"] = "fail"
            result["msg"] = "用户不存在"

        return result 
开发者ID:small99,项目名称:AutoLink,代码行数:21,代码来源:user.py

示例9: verify_password

# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import check_password_hash [as 别名]
def verify_password(self, password):
        return check_password_hash(self.password_hash, password) 
开发者ID:PacktPublishing,项目名称:Mastering-Python-Networking-Second-Edition,代码行数:4,代码来源:chapter9_9.py

示例10: check_password

# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import check_password_hash [as 别名]
def check_password(self, password: str) -> bool:
        """检查密码是否正确"""
        return check_password_hash(self.password, password) 
开发者ID:everyclass,项目名称:everyclass-server,代码行数:5,代码来源:user.py

示例11: check_password

# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import check_password_hash [as 别名]
def check_password(self, password):
        """Check hashed password."""
        return check_password_hash(self.password, password) 
开发者ID:hackersandslackers,项目名称:flask-session-tutorial,代码行数:5,代码来源:models.py

示例12: validate_login

# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import check_password_hash [as 别名]
def validate_login(user):
    db_users = json.load(open('users.json'))
    if not db_users.get(user['username']):
        return False
    stored_password = db_users[user['username']]['password']
    if check_password_hash(stored_password, user['password']):
        return True
    return False 
开发者ID:flask-extensions,项目名称:flask_simplelogin,代码行数:10,代码来源:manage.py

示例13: check_password

# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import check_password_hash [as 别名]
def check_password(self, raw_password):
        return check_password_hash(self.password, raw_password) 
开发者ID:honmaple,项目名称:maple-file,代码行数:4,代码来源:model.py

示例14: verify_password

# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import check_password_hash [as 别名]
def verify_password(self, password):
        return check_password_hash(self.password_hash, password)

    # Gravatar提供用户头像 
开发者ID:Blackyukun,项目名称:Simpleblog,代码行数:6,代码来源:models.py

示例15: check_auth

# 需要导入模块: from werkzeug import security [as 别名]
# 或者: from werkzeug.security import check_password_hash [as 别名]
def check_auth(username, password):
    if sys.version_info.major == 3:
        username = username.encode('windows-1252')
    user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) ==
                                            username.decode('utf-8').lower()).first()
    return bool(user and check_password_hash(str(user.password), password)) 
开发者ID:janeczku,项目名称:calibre-web,代码行数:8,代码来源:opds.py


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