diff --git a/.env b/.env index a98864b..373fdc7 100644 --- a/.env +++ b/.env @@ -15,8 +15,8 @@ VERIFICATION_SECRET=my-email-verification-secret EMAIL_HOST=smtp.mailtrap.io EMAIL_PORT=587 -EMAIL_USERNAME=4aeca0c9318dd2 -EMAIL_PASSWORD=a987a0e0eac00d +EMAIL_USERNAME=af7917ee09173f +EMAIL_PASSWORD=dbd2433183aa32 EMAIL_FROM=admin@admin.com JWT_PRIVATE_KEY=LS0tLS1CRUdJTiBSU0EgUFJJVkFURSBLRVktLS0tLQpNSUlCT2dJQkFBSkJBSSs3QnZUS0FWdHVQYzEzbEFkVk94TlVmcWxzMm1SVmlQWlJyVFpjd3l4RVhVRGpNaFZuCi9KVHRsd3h2a281T0pBQ1k3dVE0T09wODdiM3NOU3ZNd2xNQ0F3RUFBUUpBYm5LaENOQ0dOSFZGaHJPQ0RCU0IKdmZ2ckRWUzVpZXAwd2h2SGlBUEdjeWV6bjd0U2RweUZ0NEU0QTNXT3VQOXhqenNjTFZyb1pzRmVMUWlqT1JhUwp3UUloQU84MWl2b21iVGhjRkltTFZPbU16Vk52TGxWTW02WE5iS3B4bGh4TlpUTmhBaUVBbWRISlpGM3haWFE0Cm15QnNCeEhLQ3JqOTF6bVFxU0E4bHUvT1ZNTDNSak1DSVFEbDJxOUdtN0lMbS85b0EyaCtXdnZabGxZUlJPR3oKT21lV2lEclR5MUxaUVFJZ2ZGYUlaUWxMU0tkWjJvdXF4MHdwOWVEejBEWklLVzVWaSt6czdMZHRDdUVDSUVGYwo3d21VZ3pPblpzbnU1clBsTDJjZldLTGhFbWwrUVFzOCtkMFBGdXlnCi0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0t diff --git a/Makefile b/Makefile index 9de29e1..fa16be3 100644 --- a/Makefile +++ b/Makefile @@ -2,4 +2,13 @@ dev: docker-compose up -d dev-down: - docker-compose down \ No newline at end of file + docker-compose down + +push-migration: + alembic upgrade head + +start-server: + uvicorn app.main:app --reload + +install-modules: + pip install fastapi[all] fastapi-mail==1.2.2 fastapi-jwt-auth[asymmetric] passlib[bcrypt] alembic SQLAlchemy psycopg2 \ No newline at end of file diff --git a/app/email.py b/app/email.py index adbeb6c..0bdcf49 100644 --- a/app/email.py +++ b/app/email.py @@ -32,8 +32,8 @@ async def sendMail(self, subject, template): MAIL_FROM=settings.EMAIL_FROM, MAIL_PORT=settings.EMAIL_PORT, MAIL_SERVER=settings.EMAIL_HOST, - MAIL_TLS=True, - MAIL_SSL=False, + MAIL_STARTTLS=False, + MAIL_SSL_TLS=False, USE_CREDENTIALS=True, VALIDATE_CERTS=True ) diff --git a/app/routers/post.py b/app/routers/post.py index afe0951..1552ef5 100644 --- a/app/routers/post.py +++ b/app/routers/post.py @@ -38,7 +38,8 @@ def update_post(id: str, post: schemas.UpdatePostSchema, db: Session = Depends(g if updated_post.user_id != uuid.UUID(user_id): raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail='You are not allowed to perform this action') - post_query.update(post.dict(), synchronize_session=False) + post.user_id = user_id + post_query.update(post.dict(exclude_unset=True), synchronize_session=False) db.commit() return updated_post @@ -60,7 +61,7 @@ def delete_post(id: str, db: Session = Depends(get_db), user_id: str = Depends(r raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=f'No post with this id: {id} found') - if post.owner_id != user_id: + if str(post.user_id) != user_id: raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail='You are not allowed to perform this action') post_query.delete(synchronize_session=False) diff --git a/requirements.txt b/requirements.txt index 2c14003..095a868 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,46 +1,44 @@ -alembic==1.8.0 -anyio==3.6.1 -asgiref==3.5.2 -autopep8==1.6.0 -bcrypt==3.2.2 -certifi==2022.6.15 +aiosmtplib==1.1.7 +alembic==1.9.0 +anyio==3.6.2 +bcrypt==4.0.1 +blinker==1.5 +certifi==2022.12.7 cffi==1.15.1 -charset-normalizer==2.1.0 click==8.1.3 -colorama==0.4.5 +colorama==0.4.6 cryptography==3.4.8 dnspython==2.2.1 -email-validator==1.2.1 -fastapi==0.78.0 +email-validator==1.3.0 +fastapi==0.87.0 fastapi-jwt-auth==0.5.0 -greenlet==1.1.2 -h11==0.13.0 -httptools==0.4.0 -idna==3.3 +fastapi-mail==1.2.2 +greenlet==2.0.1 +h11==0.14.0 +httpcore==0.16.3 +httptools==0.5.0 +httpx==0.23.1 +idna==3.4 itsdangerous==2.1.2 Jinja2==3.1.2 -Mako==1.2.1 +Mako==1.2.4 MarkupSafe==2.1.1 -orjson==3.7.6 +orjson==3.8.3 passlib==1.7.4 -psycopg2==2.9.3 -pycodestyle==2.8.0 +psycopg2==2.9.5 pycparser==2.21 -pydantic==1.9.1 +pydantic==1.10.2 PyJWT==1.7.1 -python-dotenv==0.20.0 +python-dotenv==0.21.0 python-multipart==0.0.5 PyYAML==6.0 -requests==2.28.1 +rfc3986==1.5.0 six==1.16.0 -sniffio==1.2.0 -SQLAlchemy==1.4.39 -starlette==0.19.1 -toml==0.10.2 -typing_extensions==4.3.0 -tzdata==2022.1 -ujson==5.4.0 -urllib3==1.26.9 -uvicorn==0.17.6 -watchgod==0.8.2 -websockets==10.3 +sniffio==1.3.0 +SQLAlchemy==1.4.45 +starlette==0.21.0 +typing_extensions==4.4.0 +ujson==5.6.0 +uvicorn==0.20.0 +watchfiles==0.18.1 +websockets==10.4