#!/usr/bin/env bash
set -e
ADMIN_HASH=$(docker exec compose-app-1 python -c 'import bcrypt;print(bcrypt.hashpw(b"admin123", bcrypt.gensalt(12)).decode().replace("$","\\$"))')
DEMO_HASH=$(docker exec  compose-app-1 python -c 'import bcrypt;print(bcrypt.hashpw(b"demo123",  bcrypt.gensalt(12)).decode().replace("$","\\$"))')
docker exec compose-db-1 sh -lc "mariadb -u\"\$MARIADB_USER\" -p\"\$MARIADB_PASSWORD\" \"\$MARIADB_DATABASE\" -e \
\"UPDATE users SET pass_hash='${ADMIN_HASH}' WHERE email='admin@crumb.local';
  UPDATE users SET pass_hash='${DEMO_HASH}'  WHERE email='demo@crumb.local';\""
echo "✔ admin/demo Passwörter gesetzt (admin/demo)."
