diff --git a/data/sample-api-users/src/__init__.py b/data/sample-api-users/src/__init__.py index 32deb4b..b8714f6 100644 --- a/data/sample-api-users/src/__init__.py +++ b/data/sample-api-users/src/__init__.py @@ -33,4 +33,6 @@ def create_app(script_info=None): def ctx(): return {"app": app, "db": db} - return app + with app.app_context(): + db.create_all() + return app diff --git a/data/sample-api-users/src/api/auth.py b/data/sample-api-users/src/api/auth.py index fa14c74..6bce4b1 100644 --- a/data/sample-api-users/src/api/auth.py +++ b/data/sample-api-users/src/api/auth.py @@ -54,7 +54,7 @@ class Login(Resource): access_token = user.encode_token(user.id, "access") refresh_token = user.encode_token(user.id, "refresh") - response_object = {"access_token": access_token, "refresh_token": refresh_token} + response_object = {"access_token": access_token, "refresh_token": refresh_token, "user_id": user.id} return response_object, 200 diff --git a/data/sample-api-users/src/api/models/users.py b/data/sample-api-users/src/api/models/users.py index 3a67e3a..3c8ff47 100644 --- a/data/sample-api-users/src/api/models/users.py +++ b/data/sample-api-users/src/api/models/users.py @@ -111,5 +111,8 @@ class User(db.Model): return namespace.clone( "Access and Refresh Token", cls.get_api_auth_refresh_model(namespace), - {"access_token": fields.String(required=True)}, + { + "access_token": fields.String(required=True), + "user_id": fields.Integer(readOnly=True), + }, ) diff --git a/data/sample-client-users/src/Api.ts b/data/sample-client-users/src/Api.ts index 7938628..348d79e 100644 --- a/data/sample-client-users/src/Api.ts +++ b/data/sample-client-users/src/Api.ts @@ -2,7 +2,6 @@ import { Axios, AxiosError } from "axios"; import { Credentials, Token, User, Zone } from "./Types"; const instance = new Axios({ - // baseURL: "http://api:5000/", baseURL: "/api/", headers: { accept: "application/json",