當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。