Skip to content

Commit

Permalink
update sync_deactive_user (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
SkywalkerSpace authored Apr 11, 2024
1 parent 85e1a9d commit 770bc8c
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions ldap_syncer/ldap_user_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,36 +474,14 @@ def sync_update_user(self, ldap_user, db_user, email):
logger.debug('Reactivate user [%s] success.' % email)

def sync_del_user(self, db_user, email):
"""Set user.is_active = False
"""
try:
ccnet_api.update_emailuser('DB', db_user.id, '!', db_user.is_staff, 0)
except Exception as e:
logger.warning('Deactive user [%s] failed: %s' % (email, e))
return

try:
self.cursor.execute("DELETE FROM social_auth_usersocialauth WHERE username=%s ", (email,))
except Exception as e:
logger.error('Delete user [%s] from social_auth_usersocialauth failed: %s' % (email, e))
return
logger.debug('Deactive user [%s] success.' % email)
self.duser += 1

if self.cursor:
self.del_token('api2_token', email)
self.del_token('api2_tokenv2', email)
else:
logger.debug('Failed to connect seahub db, omit delete api token for user [%s].' %
email)
try:
seafile_api.delete_repo_tokens_by_email(email)
logger.debug('Delete repo tokens for user %s success.', email)
except Exception as e:
logger.warning("Failed to delete repo tokens for user %s: %s." % (email, e))

if self.settings.load_extra_user_info_sync:
self.del_profile(email)
self.del_dept(email)

def sync_data(self, data_db, data_ldap):
# sync deleted user in ldap to db
for login_attr in self.login_attr_email_map.keys():
Expand Down

0 comments on commit 770bc8c

Please sign in to comment.