mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-14 05:05:58 +00:00
update profile user (#5985)
This commit is contained in:
parent
4efbe19381
commit
6b67a76689
@ -34,8 +34,8 @@ class User(APIView):
|
|||||||
|
|
||||||
info = {}
|
info = {}
|
||||||
info['email'] = email
|
info['email'] = email
|
||||||
info['name'] = email2nickname(email)
|
info['name'] = profile.nickname if profile and profile.nickname else ''
|
||||||
info['contact_email'] = email2contact_email(email)
|
info['contact_email'] = profile.contact_email if profile and profile.contact_email else ''
|
||||||
info['telephone'] = d_profile.telephone if d_profile else ''
|
info['telephone'] = d_profile.telephone if d_profile else ''
|
||||||
info['login_id'] = profile.login_id if 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
|
info['list_in_address_book'] = profile.list_in_address_book if profile else False
|
||||||
|
@ -1013,12 +1013,11 @@ class CustomLDAPBackend(object):
|
|||||||
|
|
||||||
username = user.username
|
username = user.username
|
||||||
if LDAP_UPDATE_USER_WHEN_LOGIN:
|
if LDAP_UPDATE_USER_WHEN_LOGIN:
|
||||||
profile_kwargs = {
|
|
||||||
'nickname': nickname,
|
|
||||||
'contact_email': contact_email,
|
|
||||||
}
|
|
||||||
try:
|
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:
|
except Exception as e:
|
||||||
logger.error(f'update ldap user failed {e}')
|
logger.error(f'update ldap user failed {e}')
|
||||||
|
|
||||||
|
@ -73,8 +73,8 @@ class AccountTest(BaseTestCase):
|
|||||||
resp = self.client.get(self.url)
|
resp = self.client.get(self.url)
|
||||||
json_resp = json.loads(resp.content)
|
json_resp = json.loads(resp.content)
|
||||||
assert json_resp['email'] == self.user_name
|
assert json_resp['email'] == self.user_name
|
||||||
assert json_resp['name'] == email2nickname(self.user_name)
|
assert json_resp['name'] == (profile.nickname if profile.nickname else '')
|
||||||
assert json_resp['contact_email'] == email2contact_email(self.user_name)
|
assert json_resp['contact_email'] == (profile.contact_email if profile.contact_email else '')
|
||||||
assert json_resp['telephone'] == d_profile.telephone
|
assert json_resp['telephone'] == d_profile.telephone
|
||||||
assert json_resp['login_id'] == profile.login_id
|
assert json_resp['login_id'] == profile.login_id
|
||||||
assert 'list_in_address_book' in json_resp
|
assert 'list_in_address_book' in json_resp
|
||||||
|
Loading…
Reference in New Issue
Block a user