chore: clean up untracked files and gitignore .claude/ directory
- Add make_superadmin utility scripts (list users, promote to super admin) - Gitignore entire .claude/ directory (agents, settings, plans) - Delete leftover tailwind-config-snippet.js and dual-mode plan doc Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -206,8 +206,8 @@ marimo/_static/
|
||||
marimo/_lsp/
|
||||
__marimo__/
|
||||
|
||||
# Claude Code (local settings with permissions/tokens)
|
||||
.claude/settings.local.json
|
||||
# Claude Code (local config, agents, settings)
|
||||
.claude/
|
||||
|
||||
# Railway CLI (local tooling)
|
||||
node_modules/
|
||||
|
||||
73
backend/make_superadmin.py
Normal file
73
backend/make_superadmin.py
Normal file
@@ -0,0 +1,73 @@
|
||||
"""Script to promote a user to super admin."""
|
||||
import asyncio
|
||||
import sys
|
||||
from sqlalchemy import select
|
||||
from app.core.database import async_session_maker
|
||||
|
||||
# Import models to ensure they're registered
|
||||
import app.models.user
|
||||
import app.models.tree
|
||||
import app.models.account
|
||||
from app.models.user import User
|
||||
|
||||
|
||||
async def make_super_admin(email: str):
|
||||
"""Promote a user to super admin by email."""
|
||||
async with async_session_maker() as db:
|
||||
result = await db.execute(select(User).where(User.email == email))
|
||||
user = result.scalar_one_or_none()
|
||||
|
||||
if not user:
|
||||
print(f"❌ User not found: {email}")
|
||||
return False
|
||||
|
||||
if user.is_super_admin:
|
||||
print(f"✅ {email} is already a super admin")
|
||||
return True
|
||||
|
||||
user.is_super_admin = True
|
||||
await db.commit()
|
||||
print(f"✅ {email} promoted to super admin")
|
||||
return True
|
||||
|
||||
|
||||
async def list_users():
|
||||
"""List all users and their admin status."""
|
||||
async with async_session_maker() as db:
|
||||
result = await db.execute(
|
||||
select(User.email, User.is_super_admin, User.is_active)
|
||||
.order_by(User.created_at)
|
||||
)
|
||||
users = result.all()
|
||||
|
||||
if not users:
|
||||
print("No users found")
|
||||
return
|
||||
|
||||
print("\n📋 Current users:")
|
||||
print("-" * 60)
|
||||
for email, is_super_admin, is_active in users:
|
||||
admin_badge = "🔑 SUPER ADMIN" if is_super_admin else ""
|
||||
active_badge = "✅" if is_active else "❌ INACTIVE"
|
||||
print(f"{active_badge} {email:40} {admin_badge}")
|
||||
print("-" * 60)
|
||||
|
||||
|
||||
async def main():
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage:")
|
||||
print(" python make_superadmin.py list - List all users")
|
||||
print(" python make_superadmin.py <email> - Promote user to super admin")
|
||||
sys.exit(1)
|
||||
|
||||
command = sys.argv[1]
|
||||
|
||||
if command == "list":
|
||||
await list_users()
|
||||
else:
|
||||
email = command
|
||||
await make_super_admin(email)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
73
backend/make_superadmin_simple.py
Normal file
73
backend/make_superadmin_simple.py
Normal file
@@ -0,0 +1,73 @@
|
||||
"""Simple script to promote a user to super admin using raw SQL."""
|
||||
import asyncio
|
||||
import sys
|
||||
from sqlalchemy import text
|
||||
from app.core.database import engine
|
||||
|
||||
|
||||
async def make_super_admin(email: str):
|
||||
"""Promote a user to super admin by email."""
|
||||
async with engine.begin() as conn:
|
||||
# Check if user exists
|
||||
result = await conn.execute(
|
||||
text("SELECT email, is_super_admin FROM users WHERE email = :email"),
|
||||
{"email": email}
|
||||
)
|
||||
row = result.fetchone()
|
||||
|
||||
if not row:
|
||||
print(f"[X] User not found: {email}")
|
||||
return False
|
||||
|
||||
if row[1]: # is_super_admin
|
||||
print(f"[OK] {email} is already a super admin")
|
||||
return True
|
||||
|
||||
# Promote to super admin
|
||||
await conn.execute(
|
||||
text("UPDATE users SET is_super_admin = TRUE WHERE email = :email"),
|
||||
{"email": email}
|
||||
)
|
||||
print(f"[OK] {email} promoted to super admin")
|
||||
return True
|
||||
|
||||
|
||||
async def list_users():
|
||||
"""List all users and their admin status."""
|
||||
async with engine.connect() as conn:
|
||||
result = await conn.execute(
|
||||
text("SELECT email, is_super_admin, is_active FROM users ORDER BY created_at")
|
||||
)
|
||||
rows = result.fetchall()
|
||||
|
||||
if not rows:
|
||||
print("No users found")
|
||||
return
|
||||
|
||||
print("\nCurrent users:")
|
||||
print("-" * 70)
|
||||
for email, is_super_admin, is_active in rows:
|
||||
admin_badge = "[SUPER ADMIN]" if is_super_admin else ""
|
||||
active_badge = "[ACTIVE]" if is_active else "[INACTIVE]"
|
||||
print(f"{active_badge:12} {email:40} {admin_badge}")
|
||||
print("-" * 60)
|
||||
|
||||
|
||||
async def main():
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage:")
|
||||
print(" python make_superadmin_simple.py list - List all users")
|
||||
print(" python make_superadmin_simple.py <email> - Promote user to super admin")
|
||||
sys.exit(1)
|
||||
|
||||
command = sys.argv[1]
|
||||
|
||||
if command == "list":
|
||||
await list_users()
|
||||
else:
|
||||
email = command
|
||||
await make_super_admin(email)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user