MCPcopy Index your code
hub / github.com/1Panel-dev/MaxKB / save

Method save

apps/users/serializers/user.py:363–383  ·  view source on GitHub ↗
(self, instance, user_id, with_valid=True)

Source from the content-addressed store, hash-verified

361
362 @transaction.atomic
363 def save(self, instance, user_id, with_valid=True):
364 if with_valid:
365 if instance.get('encrypted'):
366 instance['password'] = decrypt(instance.get('password'))
367 self.UserInstance(data=instance).is_valid(raise_exception=True)
368
369 user = User(
370 id=uuid.uuid7(),
371 email=instance.get('email'),
372 phone=instance.get('phone', ''),
373 nick_name=instance.get('nick_name', ''),
374 username=instance.get('username'),
375 password=password_encrypt(instance.get('password')),
376 role=RoleConstants.USER.name,
377 source=instance.get('source', 'LOCAL'),
378 is_active=True
379 )
380 update_user_role(instance, user, user_id)
381 set_default_permission(user.id, instance)
382 user.save()
383 return UserInstanceSerializer(user).data
384
385 class UserEditInstance(serializers.Serializer):
386 email = serializers.EmailField(

Callers 4

editMethod · 0.45
re_passwordMethod · 0.45
loginMethod · 0.45
postMethod · 0.45

Calls 8

decryptFunction · 0.90
UserClass · 0.90
password_encryptFunction · 0.90
update_user_roleFunction · 0.85
set_default_permissionFunction · 0.85
getMethod · 0.45
is_validMethod · 0.45

Tested by

no test coverage detected