flask-classful icon indicating copy to clipboard operation
flask-classful copied to clipboard

decorators not working on `before_method`?

Open janpeterka opened this issue 4 years ago • 0 comments

I recently ran into an issue with decorators. I have the following code (modified for simplification):

class RecipesView(FlaskView):
    decorators = [login_required]

    def before_request(self, name, id=None, **kwargs):
       print(current_user.full_name)

   def index(self):
      # do something

login_required using Flask-Security-Too/Flask-Login

And getting an error when an unlogged user goes to /recipes. They shouldn't get there, and they won't, but before_request runs nevertheless, raising error and not getting redirect to /login.

So, is class definition of decorators not applied to before__method_ ? I didn't find that in docs, and it doesn't make much sense in my opinion. Or am I doing something wrong?

Thanks for help and clarification :)

janpeterka avatar Jul 05 '21 08:07 janpeterka