Fix bcrypt password hashing error in admin user creation
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
- Added fallback to use bcrypt directly if passlib fails - Handles bcrypt version compatibility issue - Ensures admin user can be created even with library conflicts
This commit is contained in:
parent
121f677f34
commit
c29f4af574
@ -31,10 +31,22 @@ def create_admin_user():
|
||||
try:
|
||||
admin = db.query(User).filter(User.email == settings.admin_email).first()
|
||||
if not admin:
|
||||
try:
|
||||
hashed_password = get_password_hash(settings.admin_password)
|
||||
except Exception as hash_error:
|
||||
print(f"⚠️ Password hashing error: {hash_error}")
|
||||
print("⚠️ Using direct bcrypt hash as fallback...")
|
||||
# Fallback: use bcrypt directly to avoid passlib version issues
|
||||
import bcrypt
|
||||
hashed_password = bcrypt.hashpw(
|
||||
settings.admin_password.encode('utf-8'),
|
||||
bcrypt.gensalt()
|
||||
).decode('utf-8')
|
||||
|
||||
admin = User(
|
||||
email=settings.admin_email,
|
||||
full_name=settings.admin_full_name,
|
||||
hashed_password=get_password_hash(settings.admin_password),
|
||||
hashed_password=hashed_password,
|
||||
is_admin=True,
|
||||
is_active=True,
|
||||
must_change_password=True # Force password change on first login
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user