How to properly use flask @auth.login_required in multi-files project?

456 Views Asked by At

My Flask API REST server is becoming larger and larger so I decided to split methods (urls) into different sub files.

My previous version (single file app) worked with verify_password() callback function to override standard method as in this example: https://github.com/miguelgrinberg/REST-auth/blob/master/api.py

Now, in my new multi file project, i need to make verify_password() function accessible from all @auth.login_required decorator in any single file but i cannot find a way to make it working.

How can I do? Regards

    @auth.verify_password
    def verify_password(username, password):
        user = User.query.filter_by(username = username).first()
        if not user or not user.verify_password(password):
            return False
        g.user = user
        return True
0

There are 0 best solutions below