def current_user_id(self): if not hasattr(self, '_current_user_id'): s = self.get_cookie('S') self._current_user_id = _current_user_id = Session.id_by_b64(s) if s and not _current_user_id: self.clear_cookie('S', domain="." + HOST) return self._current_user_id or 0
def prepare(self): if not self.current_user_id: self.redirect('/login') else: session = Session.new(self.current_user_id) self.set_cookie('S', session, domain="." + HOST, expires_days=SESSION_EXPIRE)
def _session_new(self, account, user_id): session = Session.new(user_id) self.set_cookie('S', session, domain="." + HOST, expires_days=SESSION_EXPIRE) self.set_cookie('E', account, domain="auth." + HOST, expires_days=SESSION_EXPIRE)
def get(self): if self.current_user_id: self.clear_cookie('S', domain="." + HOST) Session.rm(self.current_user_id) self.redirect('/')
def get(self): if self.current_user_id: self.clear_cookie('S', domain="." + HOST) Session.rm(self.current_user_id) self.render('/new_pingstart/login/Login.html')