示例#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)
示例#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
示例#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
示例#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)