Esempio n. 1
0
 def authenticate(self, username, password):
     active = User.select().where(User.active == True)
     try:
         user = active.where(User.username == username).get()
     except User.DoesNotExist:
         return False
     else:
         if not check_password(password, user.password):
             return False
         return user
Esempio n. 2
0
    def get_logged_in_user(self):
        if session.get('logged_in'):
            if getattr(g, 'user', None):
                return g.user

            try:
                return User.select().where(
                    User.active == True,
                    User.id == session.get('user_pk')).get()
            except User.DoesNotExist:
                pass