def authenticate_by_token(callback_token):
try:
token = CallbackToken.objects.get(key=callback_token, is_active=True)
# Returning a user designates a successful authentication.
token.user = User.objects.get(pk=token.user.pk)
token.is_active = False # Mark this token as used.
token.save()
return token.user
except CallbackToken.DoesNotExist:
log.debug("drfpasswordless: Challenged with a callback token that doesn't exist.")
except User.DoesNotExist:
log.debug("drfpasswordless: Authenticated user somehow doesn't exist.")
except PermissionDenied:
log.debug("drfpasswordless: Permission denied while authenticating.")
return None
utils.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录