Skip to content

Commit b3526fa

Browse files
committed
If a session is configured to prompt for username + password, only prompt on the initial connect, not on each reconnection, which is annoying and superfluous.
1 parent 33ff2e9 commit b3526fa

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

source/mysql_connection.pas

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ TMySQLConnection = class(TComponent)
191191
FConnectionStarted: Integer;
192192
FServerStarted: Integer;
193193
FParameters: TConnectionParameters;
194+
FLoginPromptDone: Boolean;
194195
FDatabase: String;
195196
FLogPrefix: String;
196197
FOnLog: TMySQLLogEvent;
@@ -409,6 +410,7 @@ constructor TMySQLConnection.Create(AOwner: TComponent);
409410
FLogPrefix := '';
410411
FIsUnicode := False;
411412
FDatabases := TDatabaseList.Create(True);
413+
FLoginPromptDone := False;
412414
end;
413415

414416

@@ -435,13 +437,14 @@ procedure TMySQLConnection.SetActive( Value: Boolean );
435437
ExitCode: LongWord;
436438
begin
437439
if Value and (FHandle = nil) then begin
438-
// Prompt for password
439-
if FParameters.LoginPrompt then begin
440+
// Prompt for password on initial connect
441+
if FParameters.LoginPrompt and (not FLoginPromptDone) then begin
440442
UsernamePrompt := FParameters.Username;
441443
PasswordPrompt := FParameters.Password;
442444
LoginPrompt('Login to '+FParameters.Hostname+':', UsernamePrompt, PasswordPrompt);
443445
FParameters.Username := UsernamePrompt;
444446
FParameters.Password := PasswordPrompt;
447+
FLoginPromptDone := True;
445448
end;
446449

447450
// Get handle

0 commit comments

Comments
 (0)