jwt_authenticator.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:django-open-volunteering-platform 作者: OpenVolunteeringPlatform 项目源码 文件源码
def authenticate_credentials(self, payload, channel):
    """
    Returns an active user that matches the payload's user id and email.
    """
    User = get_user_model()
    username = jwt_get_username_from_payload(payload)

    if not username:
      msg = _('Invalid payload.')
      raise exceptions.AuthenticationFailed(msg)

    try:
      user = User.objects.get(email=username, channel__slug=channel)
    except User.DoesNotExist:
      msg = _('Invalid signature.')
      raise exceptions.AuthenticationFailed(msg)

    if not user.is_active:
      msg = _('User account is disabled.')
      raise exceptions.AuthenticationFailed(msg)

    return user
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号