# HG changeset patch
# User Timothy Clemans <timothy.clemans@gmail.com>
# Date 1222712479 25200
# Node ID 090db58fb30ae20607983121af2d83e295f86a4f
# Parent 7dc1a9006c8533fc568fb4d3e91337bc57bea7e5
#2407
diff -r 7dc1a9006c85 -r 090db58fb30a sage/server/notebook/avatars.py
|
a
|
b
|
|
| 57 | 57 | return 'invalid_user' |
| 58 | 58 | elif avatarId.failure_type == 'password': |
| 59 | 59 | return 'invalid_password', avatarId.username |
| | 60 | elif avatarId.failure_type == 'cookies': |
| | 61 | return 'cookies_disabled' |
| 60 | 62 | else: |
| 61 | 63 | raise ValueError, 'invalid failure type' |
| 62 | 64 | |
| … |
… |
|
| 99 | 101 | def requestAvatarId(self, credentials): |
| 100 | 102 | username = credentials.username |
| 101 | 103 | password = credentials.password |
| | 104 | if username == 'COOKIESDISABLED': |
| | 105 | return defer.succeed(FailedLogin(username, failure_type = 'cookies')) |
| | 106 | |
| 102 | 107 | try: |
| 103 | 108 | U = twist.notebook.user(username) |
| 104 | 109 | except KeyError: |
| … |
… |
|
| 185 | 190 | rsrc = twist.FailedToplevel(avatarId, problem='password', username=user_type(avatarId)[1]) |
| 186 | 191 | return (iweb.IResource, rsrc, self.logout) |
| 187 | 192 | |
| | 193 | elif T[0] == 'cookies_disabled': |
| | 194 | rsrc = twist.FailedToplevel(avatarId, problem='cookies', username=user_type(avatarId)[1]) |
| | 195 | return (iweb.IResource, rsrc, self.logout) |
| | 196 | |
| 188 | 197 | elif T == 'user': |
| 189 | 198 | rsrc = twist.UserToplevel(self.cookie, avatarId) |
| 190 | 199 | return (iweb.IResource, rsrc, self.logout) |
diff -r 7dc1a9006c85 -r 090db58fb30a sage/server/notebook/guard.py
|
a
|
b
|
|
| 264 | 264 | if request.args.get('startup_token', [''])[0]: |
| 265 | 265 | import avatars |
| 266 | 266 | return avatars.TokenCred(request.args.get('startup_token', [''])[0]) |
| 267 | | username = request.args.get('email', [''])[0] |
| 268 | | password = request.args.get('password', [''])[0] |
| | 267 | if request.headers.getHeader('cookie'): |
| | 268 | for C in request.headers.getHeader('cookie'): |
| | 269 | if C.name == 'cookie_test': |
| | 270 | username = request.args.get('email', [''])[0] |
| | 271 | password = request.args.get('password', [''])[0] |
| | 272 | else: |
| | 273 | username = password = 'COOKIESDISABLED' |
| | 274 | else: |
| | 275 | username = password = 'COOKIESDISABLED' |
| 269 | 276 | return credentials.UsernamePassword(username, password) |
| 270 | 277 | |
| 271 | 278 | def _loginSuccess(self, (iface, rsrc, logout), session, creds, segments): |
diff -r 7dc1a9006c85 -r 090db58fb30a sage/server/notebook/twist.py
|
a
|
b
|
|
| 2196 | 2196 | #child_login = LoginResource |
| 2197 | 2197 | |
| 2198 | 2198 | def render(self, ctx): |
| 2199 | | return http.Response(stream = login_page_template(notebook.get_accounts(), notebook.default_user(), recover=notebook.conf()['email'])) |
| | 2199 | response = http.Response(stream = login_page_template(notebook.get_accounts(), notebook.default_user(), recover=notebook.conf()['email'])) |
| | 2200 | response.headers.setHeader("set-cookie", [http_headers.Cookie('cookie_test', 'cookie_test')]) |
| | 2201 | return response |
| 2200 | 2202 | |
| 2201 | 2203 | class FailedToplevel(Toplevel): |
| 2202 | 2204 | def __init__(self, info, problem, username=None): |
| … |
… |
|
| 2210 | 2212 | # If published pages were disabled, then this should be disabled too. |
| 2211 | 2213 | if self.problem == 'username': |
| 2212 | 2214 | return http.Response(stream = login_page_template(notebook.get_accounts(), notebook.default_user(), is_username_error=True, recover=notebook.conf()['email'])) |
| | 2215 | elif self.problem == 'password': |
| | 2216 | return http.Response(stream = login_page_template(notebook.get_accounts(), self.username, is_password_error=True, recover=notebook.conf()['email'])) |
| 2213 | 2217 | else: |
| 2214 | | return http.Response(stream = login_page_template(notebook.get_accounts(), self.username, is_password_error=True, recover=notebook.conf()['email'])) |
| | 2218 | return http.Response(stream = message("Please enable cookies and try again.")) |
| 2215 | 2219 | |
| 2216 | 2220 | |
| 2217 | 2221 | class UserToplevel(Toplevel): |