Skip to content

Commit d4d8e69

Browse files
committed
updated seeder to skip users and ranking preferences in prod, updated list of allowed admins with ppl from llsc
1 parent 65edd65 commit d4d8e69

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed

.env.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
ENV=development # set ENV=production in prod
2+
13
POSTGRES_DATABASE=llsc
24
POSTGRES_USER=postgres
35
POSTGRES_PASSWORD=postgres

backend/.env.sample

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
ENV=development # set ENV=production in prod
2+
13
POSTGRES_DATABASE=llsc
24
POSTGRES_USER=postgres
35
POSTGRES_PASSWORD=postgres

backend/app/routes/auth.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,21 @@
1919
# TODO: ADD RATE LIMITING
2020
@router.post("/register", response_model=UserCreateResponse)
2121
async def register_user(user: UserCreateRequest, user_service: UserService = Depends(get_user_service)):
22-
allowed_Admins = [
22+
allowed_admins = {
2323
2424
2525
2626
2727
28-
]
28+
29+
30+
31+
32+
33+
}
2934
if user.role == UserRole.ADMIN:
30-
if user.email not in allowed_Admins:
35+
normalized_email = user.email.lower() if user.email else ""
36+
if normalized_email not in allowed_admins:
3137
raise HTTPException(status_code=403, detail="Access denied. Admin privileges required for admin portal")
3238

3339
try:

backend/app/seeds/runner.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,40 @@ def seed_database(verbose: bool = True) -> None:
4545
Args:
4646
verbose: Whether to print detailed output
4747
"""
48+
# Check environment to determine if we should seed test data
49+
env = os.getenv("ENV", "development").lower()
50+
is_production = env == "production"
51+
4852
if verbose:
4953
print("🌱 Starting database seeding...")
54+
if is_production:
55+
print("⚠️ Production mode: Skipping test data (Users, Ranking Preferences)")
56+
else:
57+
print(f"🔧 {env.capitalize()} mode: Including test data")
5058

5159
session = get_database_session()
5260

5361
try:
5462
# Run all seed functions in dependency order
63+
# Reference data - always seed these
5564
seed_functions = [
5665
("Roles", seed_roles),
5766
("Treatments", seed_treatments),
5867
("Experiences", seed_experiences),
5968
("Qualities", seed_qualities),
6069
("Forms", seed_forms),
61-
("Users", seed_users),
62-
("Ranking Preferences", seed_ranking_preferences),
6370
("Match Status", seed_match_status),
6471
]
6572

73+
# Test data - only seed in non-production environments
74+
if not is_production:
75+
seed_functions.extend(
76+
[
77+
("Users", seed_users),
78+
("Ranking Preferences", seed_ranking_preferences),
79+
]
80+
)
81+
6682
for name, seed_func in seed_functions:
6783
if verbose:
6884
print(f"\n📦 Seeding {name}...")

0 commit comments

Comments
 (0)