1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-04-27 19:05:16 +00:00

update profile user (#5985)

This commit is contained in:
欢乐马 2024-03-19 10:52:04 +08:00 committed by GitHub
parent 4efbe19381
commit 6b67a76689
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 9 deletions

View File

@ -34,8 +34,8 @@ class User(APIView):
info = {}
info['email'] = email
info['name'] = email2nickname(email)
info['contact_email'] = email2contact_email(email)
info['name'] = profile.nickname if profile and profile.nickname else ''
info['contact_email'] = profile.contact_email if profile and profile.contact_email else ''
info['telephone'] = d_profile.telephone if d_profile else ''
info['login_id'] = profile.login_id if profile else ''
info['list_in_address_book'] = profile.list_in_address_book if profile else False

View File

@ -1013,12 +1013,11 @@ class CustomLDAPBackend(object):
username = user.username
if LDAP_UPDATE_USER_WHEN_LOGIN:
profile_kwargs = {
'nickname': nickname,
'contact_email': contact_email,
}
try:
Profile.objects.add_or_update(username, **profile_kwargs)
if nickname:
Profile.objects.add_or_update(username, nickname=nickname)
if contact_email:
Profile.objects.add_or_update(username, contact_email=contact_email)
except Exception as e:
logger.error(f'update ldap user failed {e}')

View File

@ -73,8 +73,8 @@ class AccountTest(BaseTestCase):
resp = self.client.get(self.url)
json_resp = json.loads(resp.content)
assert json_resp['email'] == self.user_name
assert json_resp['name'] == email2nickname(self.user_name)
assert json_resp['contact_email'] == email2contact_email(self.user_name)
assert json_resp['name'] == (profile.nickname if profile.nickname else '')
assert json_resp['contact_email'] == (profile.contact_email if profile.contact_email else '')
assert json_resp['telephone'] == d_profile.telephone
assert json_resp['login_id'] == profile.login_id
assert 'list_in_address_book' in json_resp