Skip to content

Commit ee1aae7

Browse files
committed
Move db.init_app to the if statement.
1 parent 3c738b8 commit ee1aae7

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

section11/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ tips:
8383
Introduce the concept of `claims`, it's just the data we choose to attach to the JWT payload. Use the `Item.delete()` endpoint as example, we make it only accessible by authenticated admins. So we need to configure the claims in `app.py` and decide whether a user is an admin, then we add a boolean claim `is_admin` to the JWT payload.
8484

8585
tips:
86-
- `get_jwt_oidentity()` now as opposed to `current_identity`
86+
- `get_jwt_identity()` now as opposed to `current_identity`
8787
- The identity is just the user id now as opposed to a UserModel object.
8888

8989
### Half protected endpoints

section11/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///data.db'
1212
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
1313
api = Api(app)
14-
db.init_app(app)
1514

1615
"""
1716
JWT related configuration. The following functions includes:
@@ -102,4 +101,5 @@ def create_tables():
102101
api.add_resource(TokenRefresh, '/refresh')
103102

104103
if __name__ == '__main__':
104+
db.init_app(app)
105105
app.run(port=5000, debug=True)

0 commit comments

Comments
 (0)