JaveaAI / project /bot /auth.py
brestok's picture
Upload 40 files
0632cd1 verified
raw
history blame
862 Bytes
import os
import uuid
from fastapi import Request
from sqladmin.authentication import AuthenticationBackend as AuthBackendAdmin
class AdminAuth(AuthBackendAdmin):
async def login(self, request: Request) -> bool:
form = await request.form()
username, password = form["username"], form["password"]
if username == 'hectool24' and password == 'hectoolshopify2024@':
request.session.update({"session": str(uuid.uuid4())})
return True
return False
async def logout(self, request: Request) -> bool:
request.session.clear()
return True
async def authenticate(self, request: Request) -> bool:
token = request.session.get("session")
if not token:
return False
return True
authentication_backend_admin = AdminAuth(secret_key=os.getenv('SECRET'))