So I am trying to create an upgrade macOS Catalina policy in self service, but I want a dialog box to appear prompting the user for their password. If that password is correct, then it will run the upgrade policy. If the password is not correct, it fails.
This is what I have so far, but the policy triggers whether the password is correct or not.
#!/bin/bash
## Get the logged in user's name
userName=$(/usr/bin/stat -f%Su /dev/console)
buttonClicked=$("/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper" -windowType "utility" -icon "/Users/Shared/logo.png" -title "WARNING!" -alignDescription center -description "Verification is required to proceed." -button1 "OK" -button2 Cancel -defaultButton 2)
if [[ "$?" == "0" ]]; then
echo "Prompting ${userName} for their login password."
userPass=$(/usr/bin/osascript -e "
on run
display dialog "To continue with macOS Catalina update" & return & return & "Enter login password for '$userName'" default answer "" buttons {"Cancel", "Ok"} default button 2 with icon POSIX file "/Users/Shared/logo.png" with text and hidden answer
set userPass to text returned of the result
return userPass
end run")
if [ "$?" == "0" ]; then
sudo jamf policy -trigger macOSCatalina
fi
fi