35 lines
1.0 KiB
PowerShell
35 lines
1.0 KiB
PowerShell
# PowerShell script to reset admin@demo.com user
|
|
# Run from: Y:\PCC\PowderCoatingApp\src\PowderCoating.Web
|
|
|
|
Write-Host "Resetting admin@demo.com user..." -ForegroundColor Yellow
|
|
|
|
# Connect to database and run SQL
|
|
$connectionString = "Server=.\SQLEXPRESS;Database=PowderCoatingDb;Trusted_Connection=true;TrustServerCertificate=true"
|
|
|
|
$sql = @"
|
|
UPDATE AspNetUsers
|
|
SET SecurityStamp = NEWID(),
|
|
ConcurrencyStamp = NEWID()
|
|
WHERE Email = 'admin@demo.com';
|
|
|
|
DELETE FROM AspNetUserClaims
|
|
WHERE UserId = (SELECT Id FROM AspNetUsers WHERE Email = 'admin@demo.com');
|
|
"@
|
|
|
|
try {
|
|
$connection = New-Object System.Data.SqlClient.SqlConnection($connectionString)
|
|
$connection.Open()
|
|
|
|
$command = $connection.CreateCommand()
|
|
$command.CommandText = $sql
|
|
$command.ExecuteNonQuery()
|
|
|
|
$connection.Close()
|
|
|
|
Write-Host "✓ User reset successfully!" -ForegroundColor Green
|
|
Write-Host "Please clear browser cookies and log in again." -ForegroundColor Cyan
|
|
}
|
|
catch {
|
|
Write-Host "Error: $_" -ForegroundColor Red
|
|
}
|