def wrapped(*args, **kwargs): # pylint: disable=missing-docstring if not check_auth( getattr(request.authorization, "username", None), getattr(request.authorization, "password", None) ): return Response( "Could not verify your access level for that URL.\n" "You have to login with proper credentials", 401, {"WWW-Authenticate": 'Basic realm="Login Required"'}, ) return func(*args, **kwargs)
def login(self, password): """Log the user in""" if Account.query.filter_by(username=self.username).first() is None or \ not check_auth(self.username, password): raise ValueError('Username or password incorrect')