功能变化: 加入浏览器单点登录

v2.x
猿小天 2023-03-28 21:29:30 +08:00
parent aba0f950b7
commit 9c585c4af1
1 changed files with 2 additions and 0 deletions

View File

@ -34,10 +34,12 @@ def CustomExceptionHandler(ex, context):
# 调用默认的异常处理函数
response = exception_handler(ex, context)
if isinstance(ex, AuthenticationFailed):
# 如果是身份验证错误
if response and response.data.get('detail') =="Given token not valid for any token type":
code = 401
msg = ex.detail
elif response and response.data.get('detail') =="Token is blacklisted":
# token在黑名单
return ErrorResponse(status=HTTP_401_UNAUTHORIZED)
else:
code = 401