Overview
Comment: | Added a catch to handle a failed Newsblur login |
---|---|
Timelines: | family | ancestors | descendants | both | develop |
Files: | files | file ages | folders |
SHA1: |
759f07e810b6811e52e040cfe1473e3a |
User & Date: | spiffy on 2011-11-20 21:04:37 |
Other Links: | branch diff | manifest | tags |
Context
2011-11-20
| ||
22:51 | Added a logout button check-in: 678f5259f2 user: spiffy tags: develop | |
21:41 | Added support for multiple users to use the site simultaneously check-in: 2ac904a27b user: spiffy tags: trunk, v0.2 | |
21:04 | Added a catch to handle a failed Newsblur login check-in: 759f07e810 user: spiffy tags: develop | |
20:49 | Added support for multiple users to use the site simultaneously check-in: 8cd4f18daf user: spiffy tags: develop | |
Changes
Modified applications/mobileblur/controllers/default.py from [5b9444c25f] to [4edf6967cb].
︙ | ︙ | |||
15 16 17 18 19 20 21 | def login(): login_form = SQLFORM.factory( Field("username", requires=IS_NOT_EMPTY()), Field("password", "password", requires=IS_NOT_EMPTY()) ) if login_form.accepts(request): | > | | | | | > > | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | def login(): login_form = SQLFORM.factory( Field("username", requires=IS_NOT_EMPTY()), Field("password", "password", requires=IS_NOT_EMPTY()) ) if login_form.accepts(request): 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) |
Modified applications/mobileblur/modules/newsblur.py from [f65190f3ac] to [a487a766ef].
︙ | ︙ | |||
22 23 24 25 26 27 28 | ''' 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 | | > > > | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | ''' 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 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. ''' url = nb_url + 'api/logout' |
︙ | ︙ |