1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-20 02:48:51 +00:00

update middleware

This commit is contained in:
孙永强
2025-08-11 16:53:12 +08:00
committed by r350178982
parent d717d768a9
commit 2bf4c1c395
6 changed files with 1 additions and 9 deletions

View File

@@ -25,7 +25,6 @@ class LazyUser(object):
class AuthenticationMiddleware(MiddlewareMixin): class AuthenticationMiddleware(MiddlewareMixin):
async_mode = False
def process_request(self, request): def process_request(self, request):
assert hasattr( assert hasattr(
request, 'session' request, 'session'

View File

@@ -34,7 +34,6 @@ class BaseMiddleware(MiddlewareMixin):
""" """
Middleware that add organization, group info to user. Middleware that add organization, group info to user.
""" """
async_mode = False
def process_request(self, request): def process_request(self, request):
username = request.user.username username = request.user.username
@@ -84,7 +83,6 @@ class BaseMiddleware(MiddlewareMixin):
class InfobarMiddleware(MiddlewareMixin): class InfobarMiddleware(MiddlewareMixin):
"""Query info bar close status, and store into request.""" """Query info bar close status, and store into request."""
async_mode = False
def get_from_db(self): def get_from_db(self):
ret = Notification.objects.all().filter(primary=1) ret = Notification.objects.all().filter(primary=1)
refresh_cache() refresh_cache()
@@ -119,7 +117,6 @@ class InfobarMiddleware(MiddlewareMixin):
class ForcePasswdChangeMiddleware(MiddlewareMixin): class ForcePasswdChangeMiddleware(MiddlewareMixin):
async_mode = False
def _request_in_black_list(self, request): def _request_in_black_list(self, request):
path = request.path path = request.path
black_list = (r'^%s$' % SITE_ROOT, r'home/.+', r'repo/.+', black_list = (r'^%s$' % SITE_ROOT, r'home/.+', r'repo/.+',
@@ -165,9 +162,9 @@ class UserAgentMiddleWare(MiddlewareMixin):
user_agents_android_search = u"(?:android)" user_agents_android_search = u"(?:android)"
user_agents_mobile_search = u"(?:mobile)" user_agents_mobile_search = u"(?:mobile)"
user_agents_tablets_search = u"(?:%s)" % u'|'.join(('ipad', 'tablet', )) user_agents_tablets_search = u"(?:%s)" % u'|'.join(('ipad', 'tablet', ))
async_mode = False
def __init__(self, get_response=None): def __init__(self, get_response=None):
super().__init__(UserAgentMiddleWare)
self.get_response = get_response self.get_response = get_response
# these for detect mobile # these for detect mobile

View File

@@ -7,7 +7,6 @@ from .handlers import get_password_hash, PASSWORD_HASH_KEY
class CheckPasswordHash(MiddlewareMixin): class CheckPasswordHash(MiddlewareMixin):
"""Logout user if value of hash key in session is not equal to current password hash""" """Logout user if value of hash key in session is not equal to current password hash"""
async_mode = False
def process_view(self, request, *args, **kwargs): def process_view(self, request, *args, **kwargs):
if getattr(request.user, 'is_authenticated') and request.user.is_authenticated: if getattr(request.user, 'is_authenticated') and request.user.is_authenticated:
if request.user.enc_password == '!': if request.user.enc_password == '!':

View File

@@ -11,7 +11,6 @@ from seahub.settings import ENABLE_LIMIT_IPADDRESS, TRUSTED_IP_LIST
class LimitIpMiddleware(MiddlewareMixin): class LimitIpMiddleware(MiddlewareMixin):
async_mode = False
def process_request(self, request): def process_request(self, request):
if not ENABLE_LIMIT_IPADDRESS: if not ENABLE_LIMIT_IPADDRESS:
return None return None

View File

@@ -33,7 +33,6 @@ class OTPMiddleware(MiddlewareMixin):
verified. As a convenience, this also installs ``user.is_verified()``, verified. As a convenience, this also installs ``user.is_verified()``,
which returns ``True`` if ``user.otp_device`` is not ``None``. which returns ``True`` if ``user.otp_device`` is not ``None``.
""" """
async_mode = False
def process_request(self, request): def process_request(self, request):
if not config.ENABLE_TWO_FACTOR_AUTH: if not config.ENABLE_TWO_FACTOR_AUTH:
return None return None

View File

@@ -19,7 +19,6 @@ class TermsAndConditionsRedirectMiddleware(MiddlewareMixin):
This middleware checks to see if the user is logged in, and if so, This middleware checks to see if the user is logged in, and if so,
if they have accepted the site terms. if they have accepted the site terms.
""" """
async_mode = False
def process_request(self, request): def process_request(self, request):
"""Process each request to app to ensure terms have been accepted""" """Process each request to app to ensure terms have been accepted"""
if not config.ENABLE_TERMS_AND_CONDITIONS: if not config.ENABLE_TERMS_AND_CONDITIONS: