1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-05-04 14:06:30 +00:00

remove share/upload links when user is deleted ()

This commit is contained in:
lian 2025-04-01 16:54:25 +08:00 committed by GitHub
parent 6614fd20a6
commit 792135a224
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -31,7 +31,7 @@ from seahub.utils import get_site_name, \
clear_token, get_system_admins, is_pro_version, IS_EMAIL_CONFIGURED clear_token, get_system_admins, is_pro_version, IS_EMAIL_CONFIGURED
from seahub.utils.mail import send_html_email_with_dj_template from seahub.utils.mail import send_html_email_with_dj_template
from seahub.utils.licenseparse import user_number_over_limit from seahub.utils.licenseparse import user_number_over_limit
from seahub.share.models import ExtraSharePermission from seahub.share.models import ExtraSharePermission, FileShare, UploadLinkShare
from seahub.utils.auth import gen_user_virtual_id from seahub.utils.auth import gen_user_virtual_id
from seahub.auth.models import SocialAuthUser from seahub.auth.models import SocialAuthUser
from seahub.repo_auto_delete.models import RepoAutoDelete from seahub.repo_auto_delete.models import RepoAutoDelete
@ -67,9 +67,11 @@ UNUSABLE_PASSWORD = '!' # This will never be a valid hash
def default_ldap_role_mapping(role): def default_ldap_role_mapping(role):
return role return role
def default_ldap_role_list_mapping(role_list): def default_ldap_role_list_mapping(role_list):
return role_list[0] if role_list else '' return role_list[0] if role_list else ''
ldap_role_mapping = default_ldap_role_mapping ldap_role_mapping = default_ldap_role_mapping
ldap_role_list_mapping = default_ldap_role_list_mapping ldap_role_list_mapping = default_ldap_role_list_mapping
USE_LDAP_ROLE_LIST_MAPPING = False USE_LDAP_ROLE_LIST_MAPPING = False
@ -81,15 +83,16 @@ if ENABLE_LDAP:
try: try:
from seahub_custom_functions import ldap_role_mapping from seahub_custom_functions import ldap_role_mapping
ldap_role_mapping = ldap_role_mapping ldap_role_mapping = ldap_role_mapping
except: except Exception:
pass pass
try: try:
from seahub_custom_functions import ldap_role_list_mapping from seahub_custom_functions import ldap_role_list_mapping
ldap_role_list_mapping = ldap_role_list_mapping ldap_role_list_mapping = ldap_role_list_mapping
USE_LDAP_ROLE_LIST_MAPPING = True USE_LDAP_ROLE_LIST_MAPPING = True
except: except Exception:
pass pass
class UserManager(object): class UserManager(object):
def create_user(self, email, password=None, is_staff=False, is_active=False): def create_user(self, email, password=None, is_staff=False, is_active=False):
@ -425,7 +428,7 @@ class UserPermissions(object):
if not settings.ENABLE_WIKI: if not settings.ENABLE_WIKI:
return False return False
return self._get_perm_by_roles('can_publish_wiki') return self._get_perm_by_roles('can_publish_wiki')
def can_choose_office_suite(self): def can_choose_office_suite(self):
if not settings.ENABLE_MULTIPLE_OFFICE_SUITE: if not settings.ENABLE_MULTIPLE_OFFICE_SUITE:
return False return False
@ -626,6 +629,10 @@ class User(object):
except Exception as e: except Exception as e:
logger.error(e) logger.error(e)
# clear share links
FileShare.objects.filter(username=username).delete()
UploadLinkShare.objects.filter(username=username).delete()
# remove current user from joined groups # remove current user from joined groups
ccnet_api.remove_group_user(username) ccnet_api.remove_group_user(username)
@ -908,7 +915,9 @@ class CustomLDAPBackend(object):
sasl_authc_id_attr, base_dn, login_attr_conf, login_attr, password, serch_filter, sasl_authc_id_attr, base_dn, login_attr_conf, login_attr, password, serch_filter,
contact_email_attr, role_attr, follow_referrals): contact_email_attr, role_attr, follow_referrals):
try: try:
admin_bind = self.ldap_bind(server_url, admin_dn, admin_dn, admin_password, enable_sasl, sasl_mechanism, follow_referrals) admin_bind = self.ldap_bind(server_url, admin_dn, admin_dn,
admin_password, enable_sasl,
sasl_mechanism, follow_referrals)
except Exception as e: except Exception as e:
raise Exception(e) raise Exception(e)
@ -943,7 +952,9 @@ class CustomLDAPBackend(object):
raise Exception('parse ldap result failed: %s' % e) raise Exception('parse ldap result failed: %s' % e)
try: try:
user_bind = self.ldap_bind(server_url, dn, authc_id, password, enable_sasl, sasl_mechanism, follow_referrals) user_bind = self.ldap_bind(server_url, dn, authc_id,
password, enable_sasl,
sasl_mechanism, follow_referrals)
except Exception as e: except Exception as e:
raise Exception(e) raise Exception(e)