Files
SkyArtShop/reset-admin-password-mongo.sh

45 lines
1.2 KiB
Bash
Raw Normal View History

#!/bin/bash
# MongoDB-Based Admin Password Reset Script
# No more SQLite issues!
if [ -z "$1" ]; then
echo "Usage: $0 <new-password>"
echo "Example: $0 MyNewPassword123!"
exit 1
fi
NEW_PASSWORD="$1"
EMAIL="admin@skyartshop.com"
echo "Resetting admin password in MongoDB..."
# Stop the service
echo "Stopping service..."
sudo systemctl stop skyartshop.service
# Update the password in appsettings.Production.json
echo "Updating password in configuration..."
cd /var/www/SkyArtShop
sudo sed -i "s|\"Password\": \".*\"|\"Password\": \"$NEW_PASSWORD\"|g" publish/appsettings.Production.json
# Delete the admin user from MongoDB to force recreation
echo "Removing old admin user from MongoDB..."
mongosh SkyArtShopDB --eval "db.AdminUsers.deleteMany({Email: '$EMAIL'})" --quiet
# Start the service (it will recreate the admin with new password)
echo "Starting service..."
sudo systemctl start skyartshop.service
sleep 3
# Check status
systemctl status skyartshop.service --no-pager | head -15
echo ""
echo "✅ Admin password has been reset in MongoDB!"
echo "Email: $EMAIL"
echo "Password: $NEW_PASSWORD"
echo ""
echo "You can now login at: https://skyarts.ddns.net/admin/login"