本文整理汇总了Python中treemap.models.User.set_password方法的典型用法代码示例。如果您正苦于以下问题:Python User.set_password方法的具体用法?Python User.set_password怎么用?Python User.set_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类treemap.models.User
的用法示例。
在下文中一共展示了User.set_password方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_user
# 需要导入模块: from treemap.models import User [as 别名]
# 或者: from treemap.models.User import set_password [as 别名]
def create_user(request):
data = json.loads(request.body)
errors = {}
for field in REQ_FIELDS:
if field not in data:
errors[field] = [trans('This field is required')]
for inputfield in data:
if inputfield not in ALL_FIELDS:
errors[inputfield] = [trans('Unrecognized field')]
if errors:
raise ValidationError(errors)
dup_username = User.objects.filter(username=data['username'])
dup_email = User.objects.filter(email=data['email'])
if dup_username.exists():
return _conflict_response(trans('Username is already in use'))
if dup_email.exists():
# BE WARNED - The iOS application relies on this error message string.
# If you change this you WILL NEED TO ALTER CODE THERE AS WELL.
return _conflict_response(trans('Email is already in use'))
user = User(**data)
# Needed to properly hash the password
user.set_password(data['password'])
user.active = True
user.save()
RegistrationProfile.objects.create_profile(user)
return {'status': 'success', 'id': user.pk}
示例2: create_user
# 需要导入模块: from treemap.models import User [as 别名]
# 或者: from treemap.models.User import set_password [as 别名]
def create_user(*args, **kwargs):
# Clearly this is just getting the api working
# it shouldn't stay here when real user stuff happens
user = User(username=kwargs["username"], email=kwargs["email"])
user.set_password(kwargs["password"])
user.save()
return user
示例3: create_mock_system_user
# 需要导入模块: from treemap.models import User [as 别名]
# 或者: from treemap.models.User import set_password [as 别名]
def create_mock_system_user():
try:
system_user = User.objects.get(id=settings.SYSTEM_USER_ID)
except Exception:
system_user = User(username="system_user",
email='[email protected]')
system_user.id = settings.SYSTEM_USER_ID
system_user.set_password('password')
system_user.save_base()
User._system_user = system_user
示例4: _create_test_user
# 需要导入模块: from treemap.models import User [as 别名]
# 或者: from treemap.models.User import set_password [as 别名]
def _create_test_user(self):
global userUUID
username = 'autotest%s' % userUUID
email = '%[email protected]' % username
userUUID += 1
User.objects.filter(email=email).delete()
u = User(username=username, email=email)
u.set_password(username)
u.save()
setattr(u, 'plain_password', username)
return u
示例5: create_user
# 需要导入模块: from treemap.models import User [as 别名]
# 或者: from treemap.models.User import set_password [as 别名]
def create_user(request):
data = json.loads(request.body)
if 'allow_email_contact' not in data:
data['allow_email_contact'] = False
errors = {}
for field in REQ_FIELDS:
if field not in data:
errors[field] = [trans('This field is required')]
for inputfield in data:
if inputfield not in ALL_FIELDS:
errors[inputfield] = [trans('Unrecognized field')]
if errors:
raise ValidationError(errors)
dup_username = User.objects.filter(username=data['username'])
dup_email = User.objects.filter(email=data['email'])
if dup_username.exists():
return _conflict_response(trans('Username is already in use'))
if dup_email.exists():
return _conflict_response(trans('Email is already in use'))
user = User(**data)
# Needed to properly hash the password
user.set_password(data['password'])
user.active = True
user.save()
RegistrationProfile.objects.create_profile(user)
return {'status': 'success', 'id': user.pk}
示例6: make_plain_user
# 需要导入模块: from treemap.models import User [as 别名]
# 或者: from treemap.models.User import set_password [as 别名]
def make_plain_user(username, password='password'):
user = User(username=username, email='%[email protected]' % username)
user.set_password(password) # hashes password, allowing authentication
user.save()
return user