本文整理汇总了Python中model.user.User.strong_password方法的典型用法代码示例。如果您正苦于以下问题:Python User.strong_password方法的具体用法?Python User.strong_password怎么用?Python User.strong_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.user.User
的用法示例。
在下文中一共展示了User.strong_password方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: register_handler
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import strong_password [as 别名]
def register_handler():
username = request.form['username']
password = request.form['password']
email = session['email']
errors = []
if not re.match('^[a-z0-9]+$', username):
errors.append("The submitted username contains non-alphanumeric characters")
if User.query.filter(User.email == email).first():
errors.append("A user with the same email already exists")
if not User.strong_password(password):
errors.append("Your password must contain a mix of letters and numerical characters and be at least 6 characters long")
# Checking if a user exists in RabbitMQ OR in our db
try:
pulse_management.user(username=username)
in_rabbitmq = True
except PulseManagementException:
in_rabbitmq = False
if in_rabbitmq:
errors.append("A user with the same username already exists in Pulse")
if User.query.filter(User.username == username).first():
errors.append("A user with the same username already exists in our database")
if errors:
signup_error = "{0}.".format(', '.join(errors))
return render_template('register.html', email=email, signup_error=signup_error)
user = User.new_user(email=email, username=username, password=password, management_api=pulse_management)
db_session.add(user)
db_session.commit()
return render_template('confirm.html')
示例2: update_info
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import strong_password [as 别名]
def update_info():
current_password = request.form['current-password']
new_password = request.form['new-password']
password_verification = request.form['new-password-verification']
if new_password:
if not g.user.valid_password(current_password):
return profile(error="The given current password isn't valid.")
elif new_password != password_verification:
return profile(error="Password verification doesn't match the password.")
elif not User.strong_password(new_password):
return profile(error="Your password must contain a mix of letters and numerical characters and be at least 6 characters long")
else:
g.user.change_password(new_password, pulse_management)
return profile(messages=["Correctly updated your password."])
else:
return profile(messages=["You didn't enter a new password."])