Commit 2be334f3 authored by Tim Peters's avatar Tim Peters

CollectPassword(): added code to supply another box to confirm

the password, and to stick on this screen until the passwords match.
I wrote this for a now-old Zope Z4I Windows installer, but there's
surely no reason to keep it secret ;-).

Also fiddled all the Pascal code to give it uniform indentation.
parent a4df0e97
...@@ -69,23 +69,25 @@ Root: HKLM; Subkey: "Software\Zope Corporation\Zope\<<VERSION>>"; Flags: uninsde ...@@ -69,23 +69,25 @@ Root: HKLM; Subkey: "Software\Zope Corporation\Zope\<<VERSION>>"; Flags: uninsde
[Code] [Code]
var var
PasswordPrompts, PasswordValues : array of String; PasswordPrompts, PasswordValues: array of String;
PasswordChars : array of char; PasswordChars: array of char;
Password: string;
DataDirValues: array of String; DataDirValues: array of String;
DataDir: String;
Password : string;
DataDir : String;
function InitializeSetup(): Boolean; function InitializeSetup(): Boolean;
begin begin
{ set up password data structures } { set up password data structures }
SetArrayLength(PasswordPrompts, 1); SetArrayLength(PasswordPrompts, 2);
PasswordPrompts[0] := 'Password:'; PasswordPrompts[0] := 'Password:';
SetArrayLength(PasswordValues, 1); PasswordPrompts[1] := 'Confirm password:';
SetArrayLength(PasswordValues, 2);
PasswordValues[0] := ''; PasswordValues[0] := '';
SetArrayLength(PasswordChars, 1); PasswordValues[1] := '';
SetArrayLength(PasswordChars, 2);
PasswordChars[0] := '*'; PasswordChars[0] := '*';
PasswordChars[1] := '*';
Password := ''; Password := '';
{ set up data dir data structures } { set up data dir data structures }
...@@ -106,8 +108,8 @@ begin ...@@ -106,8 +108,8 @@ begin
ScriptDlgPageSetSubCaption1('Select where Zope instance files should be installed'); ScriptDlgPageSetSubCaption1('Select where Zope instance files should be installed');
ScriptDlgPageSetSubCaption2('Select the folder to which you would like Setup to install Zope "instance" files, then click Next.'); ScriptDlgPageSetSubCaption2('Select the folder to which you would like Setup to install Zope "instance" files, then click Next.');
if DataDir = '' then DataDir:= 'C:\Zope-Instance'; if DataDir = '' then DataDir := 'C:\Zope-Instance';
if DataDirValues[0] <> '' then DataDirValues[0]:= ''; if DataDirValues[0] <> '' then DataDirValues[0] := '';
{ Ask for a dir until the user has approved one or clicked Back or Cancel } { Ask for a dir until the user has approved one or clicked Back or Cancel }
...@@ -121,32 +123,48 @@ begin ...@@ -121,32 +123,48 @@ begin
MsgBox(SetupMessage(msgInvalidPath), mbError, MB_OK); MsgBox(SetupMessage(msgInvalidPath), mbError, MB_OK);
end; end;
if FileOrDirExists(DataDir) then begin if FileOrDirExists(DataDir) then begin
DirOk := MsgBox('Directory Exists' #13#13 'The directory ' + DataDir + ' already exists. Would you like to create instance files in that directory anyway?', mbConfirmation, MB_YESNO) = idYes; DirOk := MsgBox('Directory Exists' #13#13 'The directory ' +
DataDir + ' already exists. Would you like to create ' +
'instance files in that directory anyway?',
mbConfirmation, MB_YESNO) = idYes;
end; end;
if not DirOk then Next := InputDir(False, DataDirValues[0], DataDir); if not DirOk then Next := InputDir(False, DataDirValues[0], DataDir);
end; end;
Result:=Next; Result := Next;
end; end;
function CollectPassword(): Boolean; function CollectPassword(): Boolean;
var var
Next: Boolean; Next: Boolean;
gotPassword: Boolean;
begin begin
ScriptDlgPageSetSubCaption1('Specify administrator password'); ScriptDlgPageSetSubCaption1('Specify administrator password');
ScriptDlgPageSetSubCaption2('The login name for your Zope administrator account is "admin". When you first connect to the Zope management interface, you will need to login using the "admin" username and the password you specify below.'); ScriptDlgPageSetSubCaption2('The login name for your Zope administrator ' +
Next := InputQueryArrayEx(PasswordPrompts, PasswordChars, PasswordValues); 'account is "admin". When you first connect to the Zope management ' +
'interface, you will need to login using the "admin" username and ' +
'the password you specify below.');
while Next and (PasswordValues[0] = '') do begin gotPassword := False;
MsgBox('You must enter an administrator password', mbError, MB_OK) repeat
Next := InputQueryArrayEx(PasswordPrompts, PasswordChars, PasswordValues); Next := InputQueryArrayEx(PasswordPrompts, PasswordChars, PasswordValues);
if Next then begin
if PasswordValues[0] = '' then
MsgBox('You must enter an administrator password', mbError, MB_OK)
else if PasswordValues[0] <> PasswordValues[1] then
MsgBox('Please try again -- the passwords don''t match',
mbError, MB_OK)
else begin
gotPassword := True;
Password := PasswordValues[0]
end
end; end;
Password := PasswordValues[0]; until gotPassword or not Next;
Result:=Next;
Result := Next;
end; end;
function DoInstanceHome():Boolean; function DoInstanceHome(): Boolean;
var var
S : String; S : String;
begin begin
...@@ -182,8 +200,8 @@ begin ...@@ -182,8 +200,8 @@ begin
while (CurSubPage >=0) and (CurSubPage <=1) and not Terminated do begin while (CurSubPage >=0) and (CurSubPage <=1) and not Terminated do begin
case CurSubPage of case CurSubPage of
0: Next:=CollectInstanceDir(); 0: Next := CollectInstanceDir();
1: Next:=CollectPassword(); 1: Next := CollectPassword();
end; end;
if Next then CurSubPage := CurSubPage +1 else CurSubPage := CurSubPage -1; if Next then CurSubPage := CurSubPage +1 else CurSubPage := CurSubPage -1;
end; end;
...@@ -193,9 +211,9 @@ begin ...@@ -193,9 +211,9 @@ begin
else else
Result := not Next; Result := not Next;
ScriptDlgPageClose(not Result); ScriptDlgPageClose(not Result);
end; end;
Result:=Next;
Result := Next;
end; end;
function NextButtonClick(CurPage: Integer): Boolean; function NextButtonClick(CurPage: Integer): Boolean;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment