authentication.py 文件源码

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

项目:service-notifications 作者: rehive 项目源码 文件源码
def authenticate(self, request):
        token = self.get_auth_header(request)
        #token = "" #Overide token for testing

        rehive = Rehive(token)

        try:
            user = rehive.user.get()
        except APIException:
            raise exceptions.AuthenticationFailed(_('Invalid user'))

        try:
            company = Company.objects.get(identifier=user['company'])
        except Company.DoesNotExist:
            raise exceptions.AuthenticationFailed(_("Inactive company."))

        user, created = User.objects.get_or_create(
            identifier=uuid.UUID(user['identifier']).hex,
            company=company)

        return user, token
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号