Spaces:
Running

axeronis commited on
Commit
3ec7ca8
·
1 Parent(s): 50d41d0

fix: Resolve login 401 (Case-insensitive email)

Browse files
backend/app/api/auth.py CHANGED
@@ -1,5 +1,6 @@
1
  from fastapi import APIRouter, Depends, HTTPException, status, Request
2
  from sqlmodel import select
 
3
  from sqlmodel.ext.asyncio.session import AsyncSession
4
  from pydantic import BaseModel, EmailStr
5
  from typing import Optional
@@ -207,9 +208,10 @@ async def login(
207
  Authenticate user and return JWT token.
208
  Rate limit: 10 requests per minute per IP
209
  """
210
- # Find user by email
 
211
  result = await session.execute(
212
- select(User).where(User.email == body.email)
213
  )
214
  user = result.scalar_one_or_none()
215
 
 
1
  from fastapi import APIRouter, Depends, HTTPException, status, Request
2
  from sqlmodel import select
3
+ from sqlalchemy import func
4
  from sqlmodel.ext.asyncio.session import AsyncSession
5
  from pydantic import BaseModel, EmailStr
6
  from typing import Optional
 
208
  Authenticate user and return JWT token.
209
  Rate limit: 10 requests per minute per IP
210
  """
211
+
212
+ # Find user by email (case-insensitive)
213
  result = await session.execute(
214
+ select(User).where(func.lower(User.email) == body.email.lower())
215
  )
216
  user = result.scalar_one_or_none()
217
 
backend/scripts/create_superuser.py CHANGED
@@ -13,7 +13,7 @@ from app.models.tenant import Tenant
13
  from app.core.security import get_password_hash
14
 
15
  async def create_superuser():
16
- email = "Axeroni.s2@gmail.com"
17
  password = "admin" # Default password
18
 
19
  print(f"Creating superuser: {email}")
 
13
  from app.core.security import get_password_hash
14
 
15
  async def create_superuser():
16
+ email = "axeroni.s2@gmail.com"
17
  password = "admin" # Default password
18
 
19
  print(f"Creating superuser: {email}")