예제 #1
0
 def find_user(cls, session_id):
     s = cls.one(session_id=session_id)
     if s is None or s.expired():
         return User.guest()
     else:
         u = User.one(id=s.user_id)
         if u is None:
             return User.guest()
         else:
             return u
예제 #2
0
def current_user(request):
    if 'session_id' in request.cookies:
        session_id = request.cookies['session_id']
        u = Session.find_user(session_id=session_id)
        return u
    else:
        return User.guest()