No SQLModel
This commit is contained in:
1 parent
5f0e8c11b4
commit
9964fbf044
16 files changed
+91
-84
No files matched your search
@@ -8,8 +8,8 @@ from starlette.authentication import (
|
||||
)
|
||||
from starlette.requests import HTTPConnection
|
||||
from starlette.responses import JSONResponse, Response
|
||||
from sqlalchemy.orm import selectinload
|
||||
from sqlmodel import Session, select
|
||||
from sqlalchemy.orm import selectinload, Session
|
||||
from sqlalchemy import select
|
||||
|
||||
from loon.web.db import engine
|
||||
from loon.web.users.models import User
|
||||
@@ -63,9 +63,9 @@ class JWTAuthBackend(AuthenticationBackend):
|
||||
raise AuthenticationError("Invalid or expired token")
|
||||
|
||||
with Session(engine) as session:
|
||||
user = session.exec(
|
||||
user = session.execute(
|
||||
select(User).where(User.id == user_id).options(selectinload(User.minecraft_user))
|
||||
).first()
|
||||
).scalars().first()
|
||||
|
||||
if user is None:
|
||||
raise AuthenticationError("User not found")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from fastapi import APIRouter, HTTPException, Request, status
|
||||
from sqlmodel import Session, select
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy.orm import Session
|
||||
|
||||
from loon.web import limiter
|
||||
from loon.web.auth.middleware import authenticated
|
||||
@@ -17,7 +18,7 @@ router = APIRouter(prefix="/auth", tags=["auth"])
|
||||
async def get_jwt(request: Request, body: JWTRequest) -> JWTResponse:
|
||||
with Session(engine) as session:
|
||||
statement = select(User).where(User.internal_username == body.username)
|
||||
user = session.exec(statement).first()
|
||||
user = session.execute(statement).scalars().first()
|
||||
|
||||
if user is None or user.id is None or not verify_password(body.password, user.password):
|
||||
raise HTTPException(
|
||||
|
||||
Reference in new issue
Block a user