fix(auth): restrict seeded credentials exclusively to super admin and demo student in backend and api documentation
This commit is contained in:
107
backend/seed.py
107
backend/seed.py
@@ -28,110 +28,73 @@ def seed_local_database():
|
||||
print("Seeding baseline content entities...")
|
||||
|
||||
with Session(engine) as session:
|
||||
# 0. Create the baseline student users (Free, Pro, AI Coach)
|
||||
free_student_id = UUID("11111111-1111-1111-1111-111111111111")
|
||||
free_student = models.User(
|
||||
id=free_student_id,
|
||||
phone="8888888888",
|
||||
email="free@pragativeer.com",
|
||||
password_hash=DEFAULT_SEED_HASH,
|
||||
name="Amit Kumar (Free Tier)",
|
||||
# 1. Super Admin User
|
||||
admin_id = UUID("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa")
|
||||
admin_user = models.User(
|
||||
id=admin_id,
|
||||
phone="9999999998",
|
||||
email="admin@pragativeer.com",
|
||||
password_hash=bcrypt.hashpw("admin123".encode('utf-8'), bcrypt.gensalt()).decode('utf-8'),
|
||||
name="Super Admin",
|
||||
student_class=models.ClassEnum.TWELFTH,
|
||||
medium=models.MediumEnum.ENGLISH,
|
||||
target_exam=models.ExamEnum.JEE_MAIN,
|
||||
city="Patna",
|
||||
state="Bihar",
|
||||
tier=models.TierEnum.FREE,
|
||||
streak_count=1,
|
||||
city="New Delhi",
|
||||
state="Delhi",
|
||||
tier=models.TierEnum.AI_COACH,
|
||||
streak_count=0,
|
||||
last_active=datetime.utcnow()
|
||||
)
|
||||
session.add(free_student)
|
||||
session.add(admin_user)
|
||||
|
||||
pro_student_id = UUID("22222222-2222-2222-2222-222222222222")
|
||||
pro_student = models.User(
|
||||
id=pro_student_id,
|
||||
phone="7777777777",
|
||||
email="pro@pragativeer.com",
|
||||
password_hash=DEFAULT_SEED_HASH,
|
||||
name="Priya Singh (Pro Tier)",
|
||||
# 2. AI Coach Demo Student User
|
||||
student_id = UUID("b0e17378-864d-439e-8806-708dc48a891b")
|
||||
student_user = models.User(
|
||||
id=student_id,
|
||||
phone="9999999999",
|
||||
email="demo@pragativeer.com",
|
||||
password_hash=bcrypt.hashpw("Pv9#kL2$mQ8!vX4@".encode('utf-8'), bcrypt.gensalt()).decode('utf-8'),
|
||||
name="Rahul Sharma (Demo AI Coach)",
|
||||
student_class=models.ClassEnum.TWELFTH,
|
||||
medium=models.MediumEnum.ENGLISH,
|
||||
target_exam=models.ExamEnum.NEET,
|
||||
city="Kota",
|
||||
state="Rajasthan",
|
||||
tier=models.TierEnum.PRO,
|
||||
streak_count=3,
|
||||
last_active=datetime.utcnow()
|
||||
)
|
||||
session.add(pro_student)
|
||||
|
||||
# Neha Verma — full AI Coach demo profile for manager presentations
|
||||
neha_id = UUID("33333333-3333-3333-3333-333333333333")
|
||||
neha_student = models.User(
|
||||
id=neha_id,
|
||||
phone="6666666666",
|
||||
email="neha@pragativeer.com",
|
||||
password_hash=DEFAULT_SEED_HASH,
|
||||
name="Neha Verma",
|
||||
student_class=models.ClassEnum.TWELFTH,
|
||||
medium=models.MediumEnum.ENGLISH,
|
||||
target_exam=models.ExamEnum.NEET,
|
||||
target_exam=models.ExamEnum.JEE_MAIN,
|
||||
school="Delhi Public School, R.K. Puram",
|
||||
city="New Delhi",
|
||||
state="Delhi",
|
||||
tier=models.TierEnum.AI_COACH,
|
||||
trial_end=None,
|
||||
subscription_end=datetime.utcnow() + timedelta(days=345),
|
||||
streak_count=62,
|
||||
longest_streak=62,
|
||||
streak_count=6,
|
||||
longest_streak=6,
|
||||
last_active=datetime.utcnow()
|
||||
)
|
||||
session.add(neha_student)
|
||||
session.add(student_user)
|
||||
|
||||
# Seed Neha's Subscription record
|
||||
neha_subscription = models.Subscription(
|
||||
# Seed Demo Student Subscription record
|
||||
demo_subscription = models.Subscription(
|
||||
id=uuid4(),
|
||||
user_id=neha_id,
|
||||
user_id=student_id,
|
||||
tier=models.TierEnum.AI_COACH,
|
||||
billing_cycle="Annual",
|
||||
start_date=datetime.utcnow() - timedelta(days=20),
|
||||
end_date=datetime.utcnow() + timedelta(days=345),
|
||||
amount=1199900, # ₹11,999 in paise
|
||||
payment_id="PAY_NEHA_DEMO_001",
|
||||
amount=1199900,
|
||||
payment_id="PAY_DEMO_001",
|
||||
status="Active",
|
||||
auto_renew=True,
|
||||
)
|
||||
session.add(neha_subscription)
|
||||
session.add(demo_subscription)
|
||||
|
||||
# Seed Neha's Transaction record
|
||||
neha_txn = models.Transaction(
|
||||
# Seed Demo Student Transaction record
|
||||
demo_txn = models.Transaction(
|
||||
id=uuid4(),
|
||||
user_id=neha_id,
|
||||
user_id=student_id,
|
||||
amount=11999.0,
|
||||
tier="Al_Coach",
|
||||
status="Success",
|
||||
created_at=datetime.utcnow() - timedelta(days=20),
|
||||
)
|
||||
session.add(neha_txn)
|
||||
|
||||
|
||||
student_id = UUID("b0e17378-864d-439e-8806-708dc48a891b")
|
||||
student_user = models.User(
|
||||
id=student_id,
|
||||
phone="9999999999",
|
||||
email="student@pragativeer.com",
|
||||
password_hash=DEFAULT_SEED_HASH,
|
||||
name="Rahul Sharma (AI Coach Tier)",
|
||||
student_class=models.ClassEnum.TWELFTH,
|
||||
medium=models.MediumEnum.ENGLISH,
|
||||
target_exam=models.ExamEnum.JEE_MAIN,
|
||||
city="New Delhi",
|
||||
state="Delhi",
|
||||
tier=models.TierEnum.AI_COACH,
|
||||
streak_count=5,
|
||||
last_active=datetime.utcnow()
|
||||
)
|
||||
session.add(student_user)
|
||||
session.add(demo_txn)
|
||||
|
||||
admin_id = uuid4()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user