Show More
@@ -44,6 +44,24 b' class LoginHandler(IPythonHandler):' | |||||
44 |
|
44 | |||
45 | self.redirect(self.get_argument('next', default=self.base_url)) |
|
45 | self.redirect(self.get_argument('next', default=self.base_url)) | |
46 |
|
46 | |||
|
47 | @staticmethod | |||
|
48 | def get_user(handler): | |||
|
49 | """Called by handlers for identifying the current user.""" | |||
|
50 | # Can't call this get_current_user because it will collide when | |||
|
51 | # called on LoginHandler itself. | |||
|
52 | ||||
|
53 | user_id = handler.get_secure_cookie(handler.cookie_name) | |||
|
54 | # For now the user_id should not return empty, but it could eventually | |||
|
55 | if user_id == '': | |||
|
56 | user_id = 'anonymous' | |||
|
57 | if user_id is None: | |||
|
58 | # prevent extra Invalid cookie sig warnings: | |||
|
59 | handler.clear_login_cookie() | |||
|
60 | if not handler.login_available: | |||
|
61 | user_id = 'anonymous' | |||
|
62 | return user_id | |||
|
63 | ||||
|
64 | ||||
47 | @classmethod |
|
65 | @classmethod | |
48 | def validate_notebook_app_security(cls, notebook_app, ssl_options=None): |
|
66 | def validate_notebook_app_security(cls, notebook_app, ssl_options=None): | |
49 | if not notebook_app.ip: |
|
67 | if not notebook_app.ip: |
@@ -68,16 +68,9 b' class AuthenticatedHandler(web.RequestHandler):' | |||||
68 | self.clear_cookie(self.cookie_name) |
|
68 | self.clear_cookie(self.cookie_name) | |
69 |
|
69 | |||
70 | def get_current_user(self): |
|
70 | def get_current_user(self): | |
71 | user_id = self.get_secure_cookie(self.cookie_name) |
|
71 | if self.login_handler is None: | |
72 | # For now the user_id should not return empty, but it could eventually |
|
72 | return 'anonymous' | |
73 | if user_id == '': |
|
73 | return self.login_handler.get_user(self) | |
74 | user_id = 'anonymous' |
|
|||
75 | if user_id is None: |
|
|||
76 | # prevent extra Invalid cookie sig warnings: |
|
|||
77 | self.clear_login_cookie() |
|
|||
78 | if not self.login_available: |
|
|||
79 | user_id = 'anonymous' |
|
|||
80 | return user_id |
|
|||
81 |
|
74 | |||
82 | @property |
|
75 | @property | |
83 | def cookie_name(self): |
|
76 | def cookie_name(self): |
General Comments 0
You need to be logged in to leave comments.
Login now