From 8aa51e548bcae89c5c829c3371041a3aa60e0fc4 Mon Sep 17 00:00:00 2001 From: Daoud Clarke Date: Thu, 8 Dec 2022 22:23:48 +0000 Subject: [PATCH] Allow login --- mwmbl/platform/user.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mwmbl/platform/user.py b/mwmbl/platform/user.py index 4c868a0..d740724 100644 --- a/mwmbl/platform/user.py +++ b/mwmbl/platform/user.py @@ -16,6 +16,11 @@ class Register(BaseModel): password_verify: str +class Login(BaseModel): + username_or_email: str + password: str + + def create_router() -> APIRouter: router = APIRouter(prefix="/user", tags=["user"]) @@ -35,4 +40,9 @@ def create_router() -> APIRouter: request = requests.post(urljoin(LEMMY_URL, "api/v3/user/register"), json=lemmy_register) return Response(content=request.content, status_code=request.status_code, media_type="text/json") + @router.post("/login") + def register_user(login: Login) -> Response: + request = requests.post(urljoin(LEMMY_URL, "api/v3/user/login"), json=login.dict()) + return Response(content=request.content, status_code=request.status_code, media_type="text/json") + return router