Exemple #1
0
    def setup(self,
              user=None,
              subst_user=None,
              current_project=None,
              selected_pks=None,
              master_instance=None,
              limit=None,
              requesting_panel=None,
              renderer=None):
        """If a `limit` is specified, this is ignored silently.
        """
        self.requesting_panel = requesting_panel
        self.master_instance = master_instance
        if user is None:
            from lino.modlib.users.utils import AnonymousUser
            self.user = AnonymousUser.instance()
        else:
            self.user = user
        self.current_project = current_project
        if renderer is None:
            renderer = settings.SITE.kernel.text_renderer
        self.renderer = renderer
        self.subst_user = subst_user

        if selected_pks is not None:
            self.set_selected_pks(*selected_pks)
Exemple #2
0
    def authenticate(self, username, password=NOT_NEEDED):
        # logger.info("20150424 authenticate %s, %s" % (username, password))

        if not username:
            return AnonymousUser.instance()

        # 20120110 : Alicia once managed to add a space char in front
        # of her username log in the login dialog.  Apache let her in
        # as " alicia".
        username = username.strip()

        try:
            user = settings.SITE.user_model.objects.get(username=username)
            if user.profile is None:
                logger.info(
                    "Could not authenticate %s : user has no profile",
                    username)
                return None
            if password != self.NOT_NEEDED:
                if not user.check_password(password):
                    logger.info(
                        "Could not authenticate %s : password mismatch",
                        username)
                    return None
                #~ logger.info("20130923 good password for %s",username)
            #~ else:
                #~ logger.info("20130923 no password needed for %s",username)
            return user
        except settings.SITE.user_model.DoesNotExist:
            logger.debug("Could not authenticate %s : no such user", username)
            return None
Exemple #3
0
    def authenticate(self, username, password=NOT_NEEDED):
        # logger.info("20150424 authenticate %s, %s" % (username, password))

        if not username:
            return AnonymousUser.instance()

        # 20120110 : Alicia once managed to add a space char in front
        # of her username log in the login dialog.  Apache let her in
        # as " alicia".
        username = username.strip()

        try:
            user = settings.SITE.user_model.objects.get(username=username)
            if user.profile is None:
                logger.info("Could not authenticate %s : user has no profile",
                            username)
                return None
            if password != self.NOT_NEEDED:
                if not user.check_password(password):
                    logger.info(
                        "Could not authenticate %s : password mismatch",
                        username)
                    return None
                #~ logger.info("20130923 good password for %s",username)
            #~ else:
            #~ logger.info("20130923 no password needed for %s",username)
            return user
        except settings.SITE.user_model.DoesNotExist:
            logger.debug("Could not authenticate %s : no such user", username)
            return None
Exemple #4
0
 def setup(self,
           user=None,
           subst_user=None,
           current_project=None,
           selected_pks=None,
           selected_rows=None,
           master_instance=None,
           limit=None,
           requesting_panel=None,
           renderer=None):
     """If a `limit` is specified, this is ignored silently.
     """
     self.requesting_panel = requesting_panel
     self.master_instance = master_instance
     if user is None:
         from lino.modlib.users.utils import AnonymousUser
         self.user = AnonymousUser.instance()
     else:
         self.user = user
     self.current_project = current_project
     if renderer is None:
         renderer = settings.SITE.kernel.text_renderer
     self.renderer = renderer
     self.subst_user = subst_user
     if selected_rows is not None:
         self.selected_rows = selected_rows
         assert selected_pks is None
     if selected_pks is not None:
         self.set_selected_pks(*selected_pks)
Exemple #5
0
    def get_user_from_request(self, request):

        user = self.authenticate(request.session.get("username"), request.session.get("password"), True)

        if user is None:
            logger.debug("Login failed from session %s", request.session)
            user = AnonymousUser.instance()

        return user
Exemple #6
0
    def get_user_from_request(self, request):

        user = self.authenticate(request.session.get('username'),
                                 request.session.get('password'), True)

        if user is None:
            logger.debug("Login failed from session %s", request.session)
            user = AnonymousUser.instance()

        return user
Exemple #7
0
    def get_user_from_request(self, request):

        # logger.info("20150428 %s get_user_from_request %s, %s" % (
        #     self.__class__.__name__,
        #     request.session.get('username'),
        #     request.session.get('password')))

        user = self.authenticate(request.session.get("username"), request.session.get("password"))

        if user is None:
            user = AnonymousUser.instance()

        return user
Exemple #8
0
    def get_user_from_request(self, request):

        # logger.info("20150428 %s get_user_from_request %s, %s" % (
        #     self.__class__.__name__,
        #     request.session.get('username'),
        #     request.session.get('password')))

        user = self.authenticate(request.session.get('username'),
                                 request.session.get('password'))

        if user is None:
            user = AnonymousUser.instance()

        return user
Exemple #9
0
    def setup(self,
              user=None,
              subst_user=None,
              current_project=None,
              selected_pks=None,
              master_instance=None,
              requesting_panel=None,
              renderer=None):
        self.requesting_panel = requesting_panel
        self.master_instance = master_instance
        if user is None:
            from lino.modlib.users.utils import AnonymousUser
            self.user = AnonymousUser.instance()
        else:
            self.user = user
        self.current_project = current_project
        if renderer is None:
            renderer = settings.SITE.kernel.text_renderer
        self.renderer = renderer
        self.subst_user = subst_user

        if selected_pks is not None:
            self.set_selected_pks(*selected_pks)
Exemple #10
0
 def get_user_from_request(self, request):
     return AnonymousUser.instance()
Exemple #11
0
 def get_user_from_request(self, request):
     return AnonymousUser.instance()