Fix bugs of original data

Return user_id on /auth/login and create database if it wasn't created
This commit is contained in:
Santiago Lo Coco 2023-11-17 13:15:16 -03:00
parent a6d6b9f4f2
commit d3e7ab1aa1
4 changed files with 8 additions and 4 deletions

View File

@ -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

View File

@ -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

View File

@ -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),
},
)

View File

@ -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",