Fix: Resolve newly created users unable to login - Add modules column support to user creation and login flow
Changes: 1. Fixed create_user_handler to properly initialize modules JSON for new users 2. Fixed edit_user_handler to manage module assignments instead of non-existent email field 3. Updated settings_handler to select modules column instead of email from users table 4. Added validate_and_repair_user_modules function in setup_complete_database.py to ensure all users have correct module assignments 5. Added create_app_license function to create development license file during database setup 6. Added ensure_app_license function to docker-entrypoint.sh for license creation on container startup 7. Added user modules validation on Flask app startup to repair any malformed modules 8. License file is automatically created with 1-year validity on deployment This ensures: - New users created via UI get proper module assignments - Existing users are validated/repaired on app startup - Non-superadmin users can login after license check passes - All deployments have a valid development license by default
This commit is contained in:
@@ -157,6 +157,37 @@ initialize_database() {
|
||||
fi
|
||||
}
|
||||
|
||||
# ============================================================================
|
||||
# LICENSE FILE CREATION
|
||||
# ============================================================================
|
||||
ensure_app_license() {
|
||||
log_info "Ensuring application license file exists..."
|
||||
|
||||
local license_file="/app/instance/app_license.json"
|
||||
|
||||
if [ -f "$license_file" ]; then
|
||||
log_success "Application license file already exists"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Create instance directory if it doesn't exist
|
||||
mkdir -p /app/instance
|
||||
|
||||
# Create a default 1-year development license
|
||||
local valid_until=$(date -d "+1 year" +%Y-%m-%d)
|
||||
local current_date=$(date +%Y-%m-%d\ %H:%M:%S)
|
||||
|
||||
cat > "$license_file" << EOF
|
||||
{
|
||||
"valid_until": "$valid_until",
|
||||
"customer": "Development",
|
||||
"license_type": "development",
|
||||
"created_at": "$current_date"
|
||||
}
|
||||
EOF
|
||||
|
||||
log_success "Application license file created (valid until: $valid_until)"
|
||||
}
|
||||
|
||||
|
||||
# ============================================================================
|
||||
@@ -208,6 +239,7 @@ main() {
|
||||
wait_for_database
|
||||
create_database_config
|
||||
initialize_database
|
||||
ensure_app_license
|
||||
run_health_check
|
||||
|
||||
echo "============================================================================"
|
||||
|
||||
Reference in New Issue
Block a user