Exemplo n.º 1
0
 def getUser(self):
     """
     If user is staff member, returns his Associated user on auth
     """
     logger.debug('REST : {}'.format(self._session))
     authId = self.getValue('auth')
     username = self.getValue('username')
     # Maybe it's root user??
     if (GlobalConfig.SUPER_USER_ALLOW_WEBACCESS.getBool(True) and
             username == GlobalConfig.SUPER_USER_LOGIN.get(True) and
             authId == -1):
         return getRootUser()
     return Authenticator.objects.get(pk=authId).users.get(name=username)
Exemplo n.º 2
0
 def getUser(self) -> 'User':
     """
     If user is staff member, returns his Associated user on auth
     """
     logger.debug('REST : %s', self._session)
     authId = self.getValue('auth')
     username = self.getValue('username')
     # Maybe it's root user??
     if (GlobalConfig.SUPER_USER_ALLOW_WEBACCESS.getBool(True)
             and username == GlobalConfig.SUPER_USER_LOGIN.get(True)
             and authId == -1):
         return getRootUser()
     return Authenticator.objects.get(pk=authId).users.get(name=username)
Exemplo n.º 3
0
    def getUser(request: HttpRequest) -> None:
        """
        Ensures request user is the correct user
        """
        user_id: str = request.session.get(USER_KEY)
        user: typing.Optional[User] = None
        if user_id:
            try:
                if user_id == ROOT_ID:
                    user = getRootUser()
                else:
                    user = User.objects.get(pk=user_id)
            except User.DoesNotExist:
                user = None

        logger.debug('User at Middleware: %s %s', user_id, user)
        request.user = user
Exemplo n.º 4
0
    def getUser(request):
        '''
        Ensures request user is the correct user
        '''
        user = request.session.get(USER_KEY)
        if user is not None:
            try:
                if user == ROOT_ID:
                    user = getRootUser()
                else:
                    user = User.objects.get(pk=user)
            except User.DoesNotExist:
                user = None

        if user is not None:
            request.user = user
        else:
            request.user = None
Exemplo n.º 5
0
    def getUser(request):
        '''
        Ensures request user is the correct user
        '''
        user = request.session.get(USER_KEY)
        if user is not None:
            try:
                if user == ROOT_ID:
                    user = getRootUser()
                else:
                    user = User.objects.get(pk=user)
            except User.DoesNotExist:
                user = None

        if user is not None:
            request.user = user
        else:
            request.user = None
Exemplo n.º 6
0
    def getUser(request):
        """
        Ensures request user is the correct user
        """
        logger.debug('Getting User on Middleware')
        user = request.session.get(USER_KEY)
        if user is not None:
            try:
                if user == ROOT_ID:
                    user = getRootUser()
                else:
                    user = User.objects.get(pk=user)
            except User.DoesNotExist:
                user = None

        if user is not None:
            request.user = user
        else:
            request.user = None
Exemplo n.º 7
0
    def getUser(request):
        """
        Ensures request user is the correct user
        """
        logger.debug('Getting User on Middleware')
        user = request.session.get(USER_KEY)
        if user is not None:
            try:
                if user == ROOT_ID:
                    user = getRootUser()
                else:
                    user = User.objects.get(pk=user)
            except User.DoesNotExist:
                user = None

        if user is not None:
            request.user = user
        else:
            request.user = None