def _check_auth(self, request_args=None, **kwargs): sessionid = self.cookies.get('sessionid') userid = self.cookies.get('userid') if sessionid and userid: session = Session.get_session(userid.value, sessionid.value) assert session is not None, \ UnAuthenticated("No session found please reauthenticate") self.session = session else: raise UnAuthenticated() yield from method(self, request_args=request_args, **kwargs)
def login(self, username, password): user = yield from User.view('by_username', self.db, key=username) user = user.first() return Session.start_session(user)