def by_credential(cls, env, login, password): try: user = env.db.query(User).filter_by(login=login).one() if check_password(password, user.password): return (user.id, None) except NoResultFound: pass return (None, None) # XXX?
def by_credential(cls, env, login, password): user = env.db.get(cls, login=login) if user and check_password(password, user.password): return user.id, None return None, u'Неправильный логин или пароль'
def check_password(self, password): return check_password(password, self.password)