File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -7,20 +7,23 @@ def seed_admin(db: Session = Depends(get_db)):
77 if existing :
88 return {"ok" : True , "note" : "Admin already exists" }
99
10+ # Fix bcrypt 72-byte password limit safely
1011 raw_password = "Edme@123"
11- if len (raw_password .encode ("utf-8" )) > 72 :
12- raw_password = raw_password [:72 ]
12+ encoded = raw_password .encode ("utf-8" )
13+ if len (encoded ) > 72 :
14+ encoded = encoded [:72 ]
15+ safe_password = encoded .decode ("utf-8" , "ignore" )
1316
1417 admin = User (
1518 name = "Admin" ,
1619 email = email ,
17- hashed_password = bcrypt .hash (raw_password ),
20+ hashed_password = bcrypt .hash (safe_password ),
1821 department = "Finance" ,
1922 role = "admin" ,
2023 manager_email = None ,
2124 )
2225 db .add (admin )
2326 db .commit ()
24- return {"ok" : True , "note" : "Admin created" }
27+ return {"ok" : True , "note" : "Admin created successfully " }
2528 except Exception as e :
2629 return {"ok" : False , "error" : str (e )}
You can’t perform that action at this time.
0 commit comments