Skip to content

Commit

Permalink
fix: 修改LoginRequiredMiddleware传参 #7625
Browse files Browse the repository at this point in the history
  • Loading branch information
huangpixu committed Dec 30, 2024
1 parent 4f2eff7 commit 760692a
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions gcloud/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,11 @@
logger = logging.getLogger("root")


def get_response(request):
# 这是一个假函数,用于模拟正常的 get_response 逻辑
return None


def page_not_found(request, exception):
if request.path.startswith(settings.STATIC_URL):
return HttpResponseNotFound()

user = LoginRequiredMiddleware(get_response).authenticate(request)
user = LoginRequiredMiddleware(lambda x: None).authenticate(request)

if user:
request.user = user
Expand All @@ -49,8 +44,8 @@ def page_not_found(request, exception):
return render(request, "core/base_vue.html", {})

# 未登录重定向到首页,跳到登录页面
if hasattr(LoginRequiredMiddleware(get_response), "is_user_forbidden"):
user_forbidden, msg = LoginRequiredMiddleware(get_response).is_user_forbidden(request)
if hasattr(LoginRequiredMiddleware(lambda x: None), "is_user_forbidden"):
user_forbidden, msg = LoginRequiredMiddleware(lambda x: None).is_user_forbidden(request)
if user_forbidden:
handler = ResponseHandler(ConfFixture, settings)
return handler.build_403_response(msg)
Expand Down

0 comments on commit 760692a

Please sign in to comment.