Double checking passwords - need some help please

Hi all,

Unfortunately ASS doesn’t support hidden text in dialogs so I’m kinda stuck trying to make my own dialogs but I’m getting really stuck.

My app requires a password check and for the users to setup thier password i need to check their first entry for a password with a entry. In normal applescript this would be very easy:

repeat
	set a to display dialog "Please enter your new password" default answer "" buttons {"OK"} default button 1 with hidden answer
	set passCheck_1 to text returned of a
	set b to display dialog "Please verify your new password" default answer "" buttons {"OK"} default button 1 with hidden answer
	set passCheck_2 to text returned of b
	if passCheck_1 is passCheck_2 then
		set thePassword to passCheck_1
		exit repeat
	else
		display dialog "Passwords do not match, please retry" buttons "OK" default button 1 with icon 0
	end if
end repeat
end

In ASS I can easily make a dialog box with hidden text, but a repeat with these dialog boxes won’t work as it errors before the user can enter a password. My approach right now is something like this (which doesn’t work):


property passCheck_1 : ""
property passCheck_2 : ""
property thePassword : ""

on passwordCheck()
	repeat
		passwordWindow(1)
		passwordWindow(2)
		if passCheck_1 is passCheck_2 then
			set thePassword to passCheck_1
			exit repeat
		else
			display dialog "Passwords do not match, please retry" buttons "OK" default button 1 with icon 0
		end if
	end repeat
end passwordCheck

on passwordWindow(theNumber)
	set text field "hiddenNumber" of window "passwordCheck" to theNumber
	show window "passwordCheck"
end passwordWindow


on clicked theObject
	set theNumber to contents of text field "hiddenNumber" of window "passwordCheck"
	if theNumber is 1 then
		set passCheck_1 to text field "passwordField" of window "passwordCheck"
	else
		set passCheck_2 to text field "passwordField" of window "passwordCheck"
	end if
end clicked

I can’t seem to get my head around solving this in ASS, any suggestions?

Could you make your own window with two password fields on it? Otherwise, what’s causing the error?

Hi Stadsman

“Unfortunately ASS doesn’t support hidden text in dialogs”

Yes it does, drag a text field to a window in your project, with the text field selected, key stroke “command 5”, then select “NSSecureTextField”, keystroke “command 8” and give it a name.

I use this bit of code sometimes.

on awake from nib theObject
display (window “_secure”) attached to window “Main”
end awake from nib
on clicked theObject
set x to contents of secure text field “password” of window “_secure”
set _newpass to x
if _newpass is “PASSWORD” then
close panel (window “_secure”)
end if

hope this helps

Budgie

Thanks Bruce,

Somehow I just overlooked doing it that way!!! :rolleyes:

I will do it that way.