本文整理汇总了Python中api.models.User.hash_password方法的典型用法代码示例。如果您正苦于以下问题:Python User.hash_password方法的具体用法?Python User.hash_password怎么用?Python User.hash_password使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api.models.User
的用法示例。
在下文中一共展示了User.hash_password方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from api.models import User [as 别名]
# 或者: from api.models.User import hash_password [as 别名]
def post(self):
req_kwargs = self.reqparse.parse_args()
user = User(email=req_kwargs['email'])
user.hash_password(req_kwargs['password'])
try:
user.save()
except ValidationError as e:
return {'message': e.message}, status.HTTP_400_BAD_REQUEST
except NotUniqueError:
return {'message': 'This email already registered'}, status.HTTP_409_CONFLICT
return {'message': 'Success'}, status.HTTP_200_OK
示例2: users_post
# 需要导入模块: from api.models import User [as 别名]
# 或者: from api.models.User import hash_password [as 别名]
def users_post():
email = request.form['email']
password = request.form['password']
info = request.form['info']
if email is None or password is None:
abort(400)
if User.query.filter_by(email=email).first() is not None:
abort(400)
user = User(email=email, info=info)
user.hash_password(password)
user.registered_on = datetime.utcnow()
db.session.add(user)
db.session.commit()
return jsonify({'status': 'OK', 'user': user.email, 'pass': password})
示例3: setUp
# 需要导入模块: from api.models import User [as 别名]
# 或者: from api.models.User import hash_password [as 别名]
def setUp(self):
self.app = create_app('testing')
self.app_context = self.app.app_context()
self.app_context.push()
db.drop_all()
db.create_all()
user = User(
username="jubril",
email="[email protected]",
)
user.hash_password("chiditheboss")
db.session.add(user)
db.session.commit()
g.user = user
self.client = self.app.test_client()
示例4: setUp
# 需要导入模块: from api.models import User [as 别名]
# 或者: from api.models.User import hash_password [as 别名]
def setUp(self):
self.app = create_app('testing')
self.app_context = self.app.app_context()
self.app_context.push()
db.create_all()
user = User(
username="jubril",
email="[email protected]",
password_hash="chiditheboss"
)
user.hash_password("chiditheboss")
db.session.add(user)
db.session.commit()
g.user = user
bucketlist = Bucketlist(name="Awesome Bucketlist", created_by=g.user.id)
bucketlist.save()
self.client = self.app.test_client()