style: deleting unnecessary file and stdoout
This commit is contained in:
parent
3554d43d15
commit
eb63ebb10f
@ -26,8 +26,6 @@ async def get_user(connection: AsyncConnection, login: str) -> Optional[User]:
|
||||
user_db_cursor = await connection.execute(query)
|
||||
user_db = user_db_cursor.one_or_none()
|
||||
|
||||
print("Raw user data from DB:", user_db)
|
||||
|
||||
if not user_db:
|
||||
return None, None
|
||||
|
||||
|
@ -64,15 +64,15 @@ async def login_for_access_token(
|
||||
|
||||
user = await authenticate_user(connection, user.login, user.password)
|
||||
|
||||
print("login_for_access_token", user)
|
||||
# print("login_for_access_token", user)
|
||||
|
||||
if not user:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Incorrect username or password",
|
||||
# headers={"WWW-Authenticate": "Bearer"},
|
||||
|
||||
)
|
||||
|
||||
access_token_expires = timedelta(
|
||||
minutes=get_settings().ACCESS_TOKEN_EXPIRE_MINUTES)
|
||||
|
||||
@ -91,7 +91,6 @@ async def login_for_access_token(
|
||||
|
||||
refresh_token_expires_time = datetime.now(timezone.utc) + refresh_token_expires
|
||||
|
||||
|
||||
await add_new_refresh_token(connection,refresh_token,refresh_token_expires_time,user)
|
||||
|
||||
Authorize.set_refresh_cookies(refresh_token)
|
||||
@ -113,8 +112,7 @@ async def refresh(
|
||||
):
|
||||
|
||||
refresh_token = request.cookies.get("refresh_token_cookie")
|
||||
print("Refresh Token:", refresh_token)
|
||||
|
||||
# print("Refresh Token:", refresh_token)
|
||||
|
||||
if not refresh_token:
|
||||
raise HTTPException(status_code=401, detail="Refresh token is missing")
|
||||
@ -123,7 +121,7 @@ async def refresh(
|
||||
|
||||
Authorize.jwt_refresh_token_required()
|
||||
current_user = Authorize.get_jwt_subject()
|
||||
print(current_user)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
|
||||
|
@ -69,7 +69,6 @@ async def create_keyring(
|
||||
keyring = await get_key_id(connection, key_id)
|
||||
|
||||
if keyring is None:
|
||||
print(key.key_type)
|
||||
user_new = await create_key(connection,key, key_id, )
|
||||
return user_new
|
||||
|
||||
|
@ -1,9 +0,0 @@
|
||||
from fastapi import HTTPException, status
|
||||
|
||||
from fastapi_jwt_auth import AuthJWT
|
||||
from fastapi.responses import JSONResponse
|
||||
|
||||
def AccessTokenValidadtion(Authorize):
|
||||
Authorize.jwt_required()
|
||||
current_user = Authorize.get_jwt_subject()
|
||||
return current_user
|
@ -1,22 +1,8 @@
|
||||
from datetime import datetime, timedelta
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import Depends, HTTPException, Request, status
|
||||
# from fastapi_jwt_auth import AuthJWT
|
||||
# from fastapi_jwt_auth.exceptions import JWTDecodeError
|
||||
# from jose import JWTError, jwt
|
||||
from loguru import logger
|
||||
from sqlalchemy.ext.asyncio import AsyncConnection
|
||||
|
||||
from api.config import get_settings
|
||||
from api.db.connection.session import get_connection_dep
|
||||
from api.db.logic.auth import get_user
|
||||
|
||||
# # from backend.schemas.users.token import TokenData
|
||||
|
||||
from api.schemas.account.account import User,Status
|
||||
from api.schemas.account.account_keyring import AccountKeyring
|
||||
|
||||
from api.utils.hasher import Hasher
|
||||
|
||||
|
||||
|
@ -45,15 +45,10 @@ class MiddlewareAccessTokenValidadtion(BaseHTTPMiddleware):
|
||||
)
|
||||
|
||||
token = auth_header.split(" ")[1]
|
||||
print(token)
|
||||
|
||||
Authorize = AuthJWT(request)
|
||||
|
||||
try:
|
||||
current_user = Authorize.get_jwt_subject()
|
||||
|
||||
print(current_user)
|
||||
|
||||
request.state.current_user = current_user
|
||||
return await call_next(request)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user