本文整理汇总了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)
示例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)
示例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
示例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)
示例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
示例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
示例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)
示例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
示例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)
示例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)
示例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)
示例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
示例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)
示例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提供用户头像
示例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))