コード例 #1
0
    def post(self, request, *args, **kw):
        username = request.POST.get('username')
        password = request.POST.get('password')
        user = auth.authenticate(
            request, username=username, password=password)
        if user is not None:
            # user.is_authenticated:
            auth.login(request, user)

        ar = BaseRequest(request)
        # mw = auth.get_auth_middleware()
        # msg = mw.authenticate(username, password, request)
        # if msg:
        #     request.session.pop('username', None)
        #     ar.error(msg)
        # else:
        #     request.session['username'] = username
        #     # request.session['password'] = password
        # ar.success(("Now logged in as %r" % username))
        #     # print "20150428 Now logged in as %r (%s)" % (username, user)
        if user is None:
            ar.error(_("Failed to log in as {}.".format(username)))
        else:
            ar.success(("Now logged in as %r" % username))
        return ar.renderer.render_action_response(ar)
コード例 #2
0
ファイル: views.py プロジェクト: lino-framework/lino
    def post(self, request, *args, **kw):
        username = request.POST.get('username')
        password = request.POST.get('password')
        user = auth.authenticate(
            request, username=username, password=password)
        if user is not None:
            # user.is_authenticated:
            auth.login(request, user)

        ar = BaseRequest(request)
        # mw = auth.get_auth_middleware()
        # msg = mw.authenticate(username, password, request)
        # if msg:
        #     request.session.pop('username', None)
        #     ar.error(msg)
        # else:
        #     request.session['username'] = username
        #     # request.session['password'] = password
        # ar.success(("Now logged in as %r" % username))
        #     # print "20150428 Now logged in as %r (%s)" % (username, user)
        if user is None:
            ar.error(_("Failed to log in as {}.".format(username)))
        else:
            ar.success(("Now logged in as %r" % username))
        return ar.renderer.render_action_response(ar)
コード例 #3
0
 def post(self, request, *args, **kw):
     username = request.POST.get('username')
     password = request.POST.get('password')
     user = auth.authenticate(username, password)
     ar = BaseRequest(request)
     if user is None:
         ar.error("Could not authenticate %r" % username)
     else:
         request.session['username'] = username
         request.session['password'] = password
         ar.success(("Now logged in as %r" % username))
         # print "20150428 Now logged in as %r (%s)" % (username, user)
     return settings.SITE.kernel.render_action_response(ar)
コード例 #4
0
ファイル: views.py プロジェクト: zhuangyan/lino
 def post(self, request, *args, **kw):
     username = request.POST.get('username')
     password = request.POST.get('password')
     user = auth.authenticate(username, password)
     ar = BaseRequest(request)
     if user is None:
         ar.error("Could not authenticate %r" % username)
     else:
         request.session['username'] = username
         request.session['password'] = password
         ar.success(("Now logged in as %r" % username))
         # print "20150428 Now logged in as %r (%s)" % (username, user)
     return settings.SITE.kernel.render_action_response(ar)
コード例 #5
0
ファイル: base.py プロジェクト: MaxTyutyunnikov/lino
    def get_callback(self, request, thread_id, button_id):
        """
        Return an existing (pending) callback. 
        This is called from `lino.ui.views.Callbacks`.
        """
        # ~ logger.info("20130409 get_callback")
        ar = BaseRequest(request)
        thread_id = int(thread_id)
        cb = self.pending_threads.pop(thread_id, None)
        # ~ d = self.pop_thread(int(thread_id))
        if cb is None:
            # ~ logger.info("20130811 No callback %r in %r" % (thread_id,self.pending_threads.keys()))
            ar.error("Unknown callback %r" % thread_id)
            return self.render_action_response(ar.response)
        # ~ buttonId = request.GET[ext_requests.URL_PARAM_'bi']
        # ~ print buttonId
        for c in cb.choices:
            if c.name == button_id:
                # ~ rv = c.func(request)
                c.func(ar)
                return self.render_action_response(ar.response)

        ar.error("Invalid button %r for callback" % (button_id, thread_id))
        return self.render_action_response(ar.response)