Flask 2.3 deprecated before_request decorerator

761 Views Asked by At

I am using flask security and sqlalchemy to store user credentials but unfortunately flask 2.3 does not suppport security = Security(app, user_datastore) any assistance would be appreicated.

I tried the following user_datastore = SQLAlchemyUserDatastore(db, User, Role) security = Security(app, user_datastore) but i get AttributeError: 'Flask' object has no attribute 'before_first_request'. Did you mean: '_got_first_request'? when i disable the security = Security(app, user_datastore), it works fine but it will not store the first time login credentials to database

2

There are 2 best solutions below

0
NickNiu On

For version 2.3.x. You can remove the decorator @before_first_request and move the code to out of function. It should work.

0
jwag On

The package Flask-Security is no longer maintained - there are a couple options- I maintain Flask-Security-Too which started from Flask-Security 3.0 and has had many improvements and is compatible with latest Flask/Werkzeug.