From 1484805c2e25fb6a6c80e01a564e67b4f4dea2ba Mon Sep 17 00:00:00 2001 From: lw2333 <2374046775@qq.com> Date: Fri, 17 Nov 2023 17:20:09 +0800 Subject: [PATCH] style: change the way authentication function --- hinghwa-dict-backend/article/views.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/hinghwa-dict-backend/article/views.py b/hinghwa-dict-backend/article/views.py index bb761341..e3fb17d0 100644 --- a/hinghwa-dict-backend/article/views.py +++ b/hinghwa-dict-backend/article/views.py @@ -310,17 +310,12 @@ def get(self, request, id) -> JsonResponse: me = {"like": False} - try: - token = token_pass(request.headers) - user = token_user(token) + # token = token_pass(request.headers) + user = request.user - # 是否是评论的作者,未添加 + # 是否是评论的作者,未添加 - except UnauthorizedException: - pass # 保留默认值 - - else: - me["like"] = comment.like_users.filter(id=user.id).exists() + me["like"] = comment.like_users.filter(id=user.id).exists() return JsonResponse({"comment": comment_all(comment), "me": me}, status=200)