Exemplo n.º 1
0
 def search(cls, keywords):
     criteria = []
     for keyword in keywords.split():
         keyword = "%" + keyword + "%"
         criteria.append(db.or_(User.name.ilike(keyword), User.email.ilike(keyword)))
     q = reduce(db.and_, criteria)
     return cls.query.filter(q)
Exemplo n.º 2
0
    def authenticate(cls, login, password):
        user = cls.query.filter(db.or_(User.name == login, User.email == login)).first()

        if user:
            authenticated = user.check_password(password)
        else:
            authenticated = False

        return user, authenticated
Exemplo n.º 3
0
    def authenticate(cls, login, password):
        user = cls.query.filter(db.or_(User.name == login,
                                       User.email == login)).first()

        if user:
            authenticated = user.check_password(password)
        else:
            authenticated = False

        return user, authenticated
Exemplo n.º 4
0
 def search(cls, keywords):
     criteria = []
     for keyword in keywords.split():
         keyword = '%' + keyword + '%'
         criteria.append(
             db.or_(
                 User.name.ilike(keyword),
                 User.email.ilike(keyword),
             ))
     q = reduce(db.and_, criteria)
     return cls.query.filter(q)