Spaces:
Running
Running
axeronis commited on
Commit ·
73f232b
1
Parent(s): 224da90
Fix: allow superuser login without verification
Browse files
backend/app/api/auth.py
CHANGED
|
@@ -271,7 +271,7 @@ async def login(
|
|
| 271 |
detail="Account is inactive"
|
| 272 |
)
|
| 273 |
|
| 274 |
-
if not user.is_verified:
|
| 275 |
# Check if verification code expired, if so regenerate and resend?
|
| 276 |
# For now, just tell them to verify
|
| 277 |
raise HTTPException(
|
|
|
|
| 271 |
detail="Account is inactive"
|
| 272 |
)
|
| 273 |
|
| 274 |
+
if not user.is_verified and not user.is_superuser:
|
| 275 |
# Check if verification code expired, if so regenerate and resend?
|
| 276 |
# For now, just tell them to verify
|
| 277 |
raise HTTPException(
|
backend/scripts/create_superuser.py
CHANGED
|
@@ -48,7 +48,8 @@ async def create_superuser():
|
|
| 48 |
tenant_id=tenant.id,
|
| 49 |
role=UserRole.OWNER,
|
| 50 |
is_active=True,
|
| 51 |
-
is_superuser=True
|
|
|
|
| 52 |
)
|
| 53 |
session.add(user)
|
| 54 |
await session.commit()
|
|
|
|
| 48 |
tenant_id=tenant.id,
|
| 49 |
role=UserRole.OWNER,
|
| 50 |
is_active=True,
|
| 51 |
+
is_superuser=True,
|
| 52 |
+
is_verified=True
|
| 53 |
)
|
| 54 |
session.add(user)
|
| 55 |
await session.commit()
|
backend/scripts/verify_admin.py
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import asyncio
|
| 2 |
+
import sys
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
# Add parent dir to path
|
| 6 |
+
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
| 7 |
+
|
| 8 |
+
from sqlmodel import select
|
| 9 |
+
from app.core.database import async_session_maker
|
| 10 |
+
from app.models.user import User
|
| 11 |
+
|
| 12 |
+
async def verify_admin():
|
| 13 |
+
email = "axeroni.s2@gmail.com"
|
| 14 |
+
|
| 15 |
+
print(f"Verifying user: {email}")
|
| 16 |
+
|
| 17 |
+
async with async_session_maker() as session:
|
| 18 |
+
# Check if user exists
|
| 19 |
+
statement = select(User).where(User.email == email)
|
| 20 |
+
result = await session.execute(statement)
|
| 21 |
+
user = result.scalars().first()
|
| 22 |
+
|
| 23 |
+
if not user:
|
| 24 |
+
print(f"User {email} not found!")
|
| 25 |
+
return
|
| 26 |
+
|
| 27 |
+
# Update verification status
|
| 28 |
+
if not user.is_verified:
|
| 29 |
+
user.is_verified = True
|
| 30 |
+
session.add(user)
|
| 31 |
+
await session.commit()
|
| 32 |
+
print(f"User {email} has been manually VERIFIED.")
|
| 33 |
+
else:
|
| 34 |
+
print(f"User {email} is ALREADY verified.")
|
| 35 |
+
|
| 36 |
+
if __name__ == "__main__":
|
| 37 |
+
if sys.platform == 'win32':
|
| 38 |
+
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
|
| 39 |
+
asyncio.run(verify_admin())
|
frontend/public/logo-v2.png
ADDED
|
Git LFS Details
|