use simpler dotenv file

This commit is contained in:
Osman Faruk Bayram 2025-05-05 16:13:41 +03:00
parent 171a94f174
commit 948eb75416
3 changed files with 4 additions and 11 deletions

View file

@ -6,6 +6,7 @@ from pydantic import BaseModel
from fastapi import Depends, HTTPException
from typing import Annotated, Optional
from fastapi.security import OAuth2PasswordBearer
from passlib.context import CryptContext
import jwt
from sqlmodel import SQLModel, Field, Session, select
from pydantic.networks import EmailStr
@ -93,7 +94,7 @@ def create_access_token(
to_encode = data.copy()
expire = datetime.now(timezone.utc) + expires_delta
to_encode.update({"exp": expire})
encoded_jwt = jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM)
encoded_jwt = jwt.encode(to_encode, SECRET_KEY, algorithm="HS256")
return encoded_jwt
@ -118,7 +119,7 @@ async def get_current_user(
headers={"WWW-Authenticate": "Bearer"},
)
try:
payload = jwt.decode(token, SECRET_KEY, algorithms=[ALGORITHM])
payload = jwt.decode(token, SECRET_KEY, algorithms=["HS256"])
token_data = TokenData(**payload)
username: Optional[str] = payload.get("sub")
if username is None: