Fixing the Credentials system. (#3390)

* Checks if password exists for the user, if it doesn't the user is prompted to create one.

It checks if the password is equal to $null using `ValidateCredentials` and if it isn't the variable will be created. If it is equal to $null, a window with text, a textbox and a button will appear asking the user to create a password. That password is then set for the user and the winget installation continues.

* Made this a little more secure

Securing the password variable when it gets created and deleting it after it's done being used.

* Forces the user to input their password and automatically puts their username into the credentials box

* Removed the second greater than 0 check
This commit is contained in:
UnaTried
2025-08-01 17:13:33 +02:00
committed by GitHub
parent cae497b2fe
commit cdd43f5e36
2 changed files with 49 additions and 8 deletions

View File

@ -97,9 +97,9 @@ Function Install-WinUtilProgramWinget {
return $true
}
$userChoice = [System.Windows.MessageBox]::Show("Do you want to attempt $($Program) installation with specific user credentials? Select 'Yes' to proceed or 'No' to skip.", "User credential Prompt", [System.Windows.MessageBoxButton]::YesNo)
if ($userChoice -eq 'Yes') {
$getcreds = Get-Credential
$userAcknowledgment = [System.Windows.MessageBox]::Show("You need to input your password to install $($Program) with specific user credentials.", "User credential Prompt", [System.Windows.MessageBoxButton]::Ok)
if ($userAcknowledgment -eq 'Ok') {
$getcreds = Get-Credential $env:USERNAME
$status = Invoke-Winget -wingetId $Program -credential $getcreds
if ($status -eq 0) {
Write-Host "$($Program) installed successfully with User prompt."