Index: applications/mobileblur/controllers/default.py ================================================================== --- applications/mobileblur/controllers/default.py +++ applications/mobileblur/controllers/default.py @@ -17,12 +17,15 @@ login_form = SQLFORM.factory( Field("username", requires=IS_NOT_EMPTY()), Field("password", "password", requires=IS_NOT_EMPTY()) ) if login_form.accepts(request): - results = newsblur.login(login_form.vars["username"], login_form.vars["password"]) - response.cookies["nb_cookie"] = newsblur.cookies["newsblur_sessionid"] - response.cookies["nb_cookie"]["path"] = "/" - print "cookie =", newsblur.cookies - redirect(URL("index")) + try: + results = newsblur.login(login_form.vars["username"], login_form.vars["password"]) + response.cookies["nb_cookie"] = newsblur.cookies["newsblur_sessionid"] + response.cookies["nb_cookie"]["path"] = "/" + print "cookie =", newsblur.cookies + redirect(URL("index")) + except Exception as ex: + login_form.insert(-1, ex.message) return dict(login_form=login_form) Index: applications/mobileblur/modules/newsblur.py ================================================================== --- applications/mobileblur/modules/newsblur.py +++ applications/mobileblur/modules/newsblur.py @@ -24,11 +24,14 @@ url = nb_url + 'api/login' results = requests.post(url, data={"username": username, "password": password}) print "results.cookies =", results.cookies print type(results.cookies) self.cookies = results.cookies - return simplejson.loads(results.content) + results = simplejson.loads(results.content) + if results["authenticated"] is False: + raise Exception("The newsblur credentials you provided are invalid") + return results def logout(self, ): ''' Logout the currently logged in user. '''