diff --git a/app/dependencies/database.py b/app/dependencies/database.py index 7ff0550..cbf875c 100644 --- a/app/dependencies/database.py +++ b/app/dependencies/database.py @@ -1,5 +1,7 @@ from pymongo import MongoClient -import os +import os, redis client = MongoClient("mongodb+srv://{0}:{1}@{2}/?retryWrites=true&w=majority&appName=AtlasApp".format(os.environ["MONGO_USER"], os.environ["MONGO_PASSWORD"], os.environ["MONGO_HOST"])) -database = client[os.environ["MONGO_DATABASE"]] \ No newline at end of file +database = client[os.environ["MONGO_DATABASE"]] + +connect_redis = redis.Redis(host=os.environ["REDIS_URL"], port=os.environ["REDIS_PORT"], decode_responses=True) \ No newline at end of file diff --git a/app/routers/mail.py b/app/routers/mail.py index 919402e..1641840 100644 --- a/app/routers/mail.py +++ b/app/routers/mail.py @@ -8,7 +8,7 @@ router = APIRouter() @router.post("/mail",tags=["mail"]) -async def read_users_me(userSingle: users.UserCreate | None = None): +async def create_user(userSingle: users.UserCreate | None = None): if userSingle is None: raise HTTPException( status_code=status.HTTP_400_BAD_REQUEST, @@ -37,4 +37,5 @@ async def read_users_me(userSingle: users.UserCreate | None = None): await fm.send_message(message, template_name="mailer.html") current_user = users.User(username=userSingle.username, password=users_token.get_password_hash(userSingle.password), email=userSingle.email) user_repository.save(current_user) - return JSONResponse(status_code=200, content={"message": "email has been sent"}) \ No newline at end of file + database.connect_redis.set(userSingle.username, key_hashed) + return JSONResponse(status_code=status.HTTP_200_OK, content={"message": "email has been sent"}) \ No newline at end of file