本文整理汇总了Python中model.user.User.hash_password方法的典型用法代码示例。如果您正苦于以下问题:Python User.hash_password方法的具体用法?Python User.hash_password怎么用?Python User.hash_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.user.User
的用法示例。
在下文中一共展示了User.hash_password方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import hash_password [as 别名]
def post(self):
args = userParser.parse_args()
email = args['email']
password = args['password']
if email is None or password is None:
abort(400)
user = User(email=email, is_activated=True)
user.hash_password(password)
try:
user.save()
except ValidationError, e:
return {'status': 'error', 'message': e.message}
示例2: post
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import hash_password [as 别名]
def post(self):
# email = request.form.get('email')
username = request.form.get('username')
password = request.form.get('password')
if username is None or password is None:
abort(400) # missing arguments
user = User(username=username)
user.hash_password(password)
try:
user.save()
except:
return {'status': 'error', 'message': 'username has already existed'}
return ({'username': user.username}, 201)
示例3: post
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import hash_password [as 别名]
def post(self):
args = userParser.parse_args()
email = args['email']
password = args['password']
if email is None or password is None:
abort(400)
user = User(email=email)
user.hash_password(password)
profile = Profile(user=user)
try:
user.save()
profile.save()
except ValidationError, e:
raise InvalidUsage(e.message)
示例4: post
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import hash_password [as 别名]
def post(self):
"""
Create a new user and send an activation email
"""
args = userParser.parse_args()
email = args['email']
password = args['password']
if email is None or password is None:
abort(400)
user = User(email=email)
user.hash_password(password)
try:
user.save()
except ValidationError, e:
return {'status': 'error', 'message': e.message}