本文整理汇总了Python中api.models.User.password方法的典型用法代码示例。如果您正苦于以下问题:Python User.password方法的具体用法?Python User.password怎么用?Python User.password使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api.models.User
的用法示例。
在下文中一共展示了User.password方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from api.models import User [as 别名]
# 或者: from api.models.User import password [as 别名]
def post(self):
args = parser.parse_args()
user = User.objects(username__iexact=args['username']).first()
if user:
abort(409, message="Username already exists.")
user = User(username=args['username'])
user.password = bcrypt.generate_password_hash(args['password'])
if args['type'] == 'individual':
user.user_type = args['type']
user.user_profile = Individual()
elif args['type'] == 'group':
user.user_type = args['type']
user.user_profile = Group()
user.save()
response = {
'username': user.username,
'email': user.email,
'type': user.user_type,
'created_at': str(user.created_at),
'updated_at': str(user.updated_at)
}
return response
示例2: create_user
# 需要导入模块: from api.models import User [as 别名]
# 或者: from api.models.User import password [as 别名]
def create_user(self, author, user, passhash, user_root):
u = User()
u.author = author
u.user_root = user_root
u.active = True
u.name = user
u.password = passhash
u.save()
示例3: adduser
# 需要导入模块: from api.models import User [as 别名]
# 或者: from api.models.User import password [as 别名]
def adduser(username):
u"""Adds user to the REST API"""
from getpass import getpass
password = getpass()
password2 = getpass(prompt='Confirm: ')
if password != password2:
sys.exit('Sorry, passwords are not matching.')
db.set(username, username)
user = User(username=username)
user.password = password
print("User {} is correctly created.".format(username))
示例4: run
# 需要导入模块: from api.models import User [as 别名]
# 或者: from api.models.User import password [as 别名]
def run(self):
api_user = User(username="testapi")
api_user.password = "testapi"
api_user.api_key = "api_key"
self.db.session.add(api_user)
self.db.session.commit()