From fe1219d5a0e105ad4ecd767b5b0508eb0152409c Mon Sep 17 00:00:00 2001 From: Jimmy Date: Sat, 4 Dec 2021 01:42:26 +1300 Subject: [PATCH] Put users_db into json file --- app/main.py | 13 ++----------- app/users.json | 9 +++++++++ 2 files changed, 11 insertions(+), 11 deletions(-) create mode 100644 app/users.json diff --git a/app/main.py b/app/main.py index e772e63..e37f914 100755 --- a/app/main.py +++ b/app/main.py @@ -7,6 +7,7 @@ from jose import JWTError, jwt from passlib.context import CryptContext from pydantic import BaseModel from os import getenv +import json # to get a string like this run: # openssl rand -hex 32 @@ -14,17 +15,7 @@ SECRET_KEY = getenv("SECRET_KEY") ALGORITHM = getenv("ALGORITHM") ACCESS_TOKEN_EXPIRE_MINUTES = int(getenv("ACCESS_TOKEN_EXPIRE_MINUTES")) - -fake_users_db = { - "johndoe": { - "username": "johndoe", - "full_name": "John Doe", - "email": "johndoe@example.com", - "hashed_password": "$2b$12$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW", - "disabled": False, - } -} - +fake_users_db = json.load(open("app/users.json")) class Token(BaseModel): access_token: str diff --git a/app/users.json b/app/users.json new file mode 100644 index 0000000..4a101e7 --- /dev/null +++ b/app/users.json @@ -0,0 +1,9 @@ +{ + "johndoe": { + "username": "johndoe", + "full_name": "John Doe", + "email": "johndoe@example.com", + "hashed_password": "$2b$12$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW", + "disabled": "False" + } +} \ No newline at end of file