234 session.mtime = time() |
234 session.mtime = time() |
235 return session |
235 return session |
236 |
236 |
237 def open_session(self, req, allow_no_cnx=True): |
237 def open_session(self, req, allow_no_cnx=True): |
238 session = self.session_manager.open_session(req, allow_no_cnx=allow_no_cnx) |
238 session = self.session_manager.open_session(req, allow_no_cnx=allow_no_cnx) |
239 cookie = req.get_cookie() |
|
240 sessioncookie = self.session_cookie(req) |
239 sessioncookie = self.session_cookie(req) |
241 cookie[sessioncookie] = session.sessionid |
240 secure = req.https and req.base_url().startswith('https://') |
242 if req.https and req.base_url().startswith('https://'): |
241 req.set_cookie(sessioncookie, session.sessionid, |
243 cookie[sessioncookie]['secure'] = True |
242 maxage=None, secure=secure) |
244 req.set_cookie(cookie, sessioncookie, maxage=None) |
|
245 if not session.anonymous_session: |
243 if not session.anonymous_session: |
246 self.session_manager.postlogin(req) |
244 self.session_manager.postlogin(req) |
247 return session |
245 return session |
248 |
246 |
249 def logout(self, req, goto_url): |
247 def logout(self, req, goto_url): |
250 """logout from the instance by cleaning the session and raising |
248 """logout from the instance by cleaning the session and raising |
251 `AuthenticationError` |
249 `AuthenticationError` |
252 """ |
250 """ |
253 self.session_manager.close_session(req.session) |
251 self.session_manager.close_session(req.session) |
254 sessioncookie = self.session_cookie(req) |
252 req.remove_cookie(self.session_cookie(req)) |
255 req.remove_cookie(req.get_cookie(), sessioncookie) |
|
256 raise LogOut(url=goto_url) |
253 raise LogOut(url=goto_url) |
257 |
254 |
258 # these are overridden by set_log_methods below |
255 # these are overridden by set_log_methods below |
259 # only defining here to prevent pylint from complaining |
256 # only defining here to prevent pylint from complaining |
260 info = warning = error = critical = exception = debug = lambda msg,*a,**kw: None |
257 info = warning = error = critical = exception = debug = lambda msg,*a,**kw: None |