Commit cbd0f858 by Michael Brachmann

fixes

parent ecc88919
...@@ -109,6 +109,18 @@ object FViewLogin: TFViewLogin ...@@ -109,6 +109,18 @@ object FViewLogin: TFViewLogin
DisplayText = 'BUF - Buffalo Police Department' DisplayText = 'BUF - Buffalo Police Department'
end> end>
end end
object btnPasskeyLogin: TWebButton
Left = 240
Top = 244
Width = 121
Height = 25
Caption = 'Sign In with Passkey'
ElementID = 'view.login.btnpasskeylogin'
HeightPercent = 100.000000000000000000
TabOrder = 5
WidthPercent = 100.000000000000000000
OnClick = btnPasskeyLoginClick
end
object XDataWebClient: TXDataWebClient object XDataWebClient: TXDataWebClient
Connection = DMConnection.AuthConnection Connection = DMConnection.AuthConnection
Left = 492 Left = 492
......
...@@ -15,12 +15,14 @@ type ...@@ -15,12 +15,14 @@ type
edtPassword: TWebEdit; edtPassword: TWebEdit;
btnShowPassword: TWebButton; btnShowPassword: TWebButton;
btnLogin: TWebButton; btnLogin: TWebButton;
btnPasskeyLogin: TWebButton;
pnlMessage: TWebPanel; pnlMessage: TWebPanel;
lblMessage: TWebLabel; lblMessage: TWebLabel;
btnCloseNotification: TWebButton; btnCloseNotification: TWebButton;
XDataWebClient: TXDataWebClient; XDataWebClient: TXDataWebClient;
lucbAgency: TWebLookupComboBox; lucbAgency: TWebLookupComboBox;
procedure btnLoginClick(Sender: TObject); procedure btnLoginClick(Sender: TObject);
procedure btnPasskeyLoginClick(Sender: TObject);
procedure btnShowPasswordClick(Sender: TObject); procedure btnShowPasswordClick(Sender: TObject);
procedure btnCloseNotificationClick(Sender: TObject); procedure btnCloseNotificationClick(Sender: TObject);
procedure WebFormCreate(Sender: TObject); procedure WebFormCreate(Sender: TObject);
...@@ -77,8 +79,6 @@ var ...@@ -77,8 +79,6 @@ var
credId: string; credId: string;
procedure OnDeviceUser(AUsername, AAgency: string); procedure OnDeviceUser(AUsername, AAgency: string);
var
passkeyHandler: TJSRawEventHandler;
begin begin
FAutoUsername := AUsername; FAutoUsername := AUsername;
FAutoAgency := AAgency; FAutoAgency := AAgency;
...@@ -91,16 +91,8 @@ var ...@@ -91,16 +91,8 @@ var
if (autoSection) autoSection.classList.remove('d-none'); if (autoSection) autoSection.classList.remove('d-none');
if (manualSection) manualSection.classList.add('d-none'); if (manualSection) manualSection.classList.add('d-none');
if (lbl) lbl.textContent = AUsername; if (lbl) lbl.textContent = AUsername;
end;
// Wire passkey button and "use different account" link via JS // "Use a different account" — pure JS show/hide
asm
var btn = document.getElementById('view.login.btnpasskeylogin');
if (btn) {
btn.addEventListener('click', function() {
document.dispatchEvent(new CustomEvent('login-passkey'));
});
}
var lnk = document.getElementById('view.login.switchmanual'); var lnk = document.getElementById('view.login.switchmanual');
if (lnk) { if (lnk) {
lnk.addEventListener('click', function(e) { lnk.addEventListener('click', function(e) {
...@@ -110,31 +102,6 @@ var ...@@ -110,31 +102,6 @@ var
}); });
} }
end; end;
passkeyHandler := procedure
var
onBeginOK: TOnBeginSuccess;
onBeginErr: TOnLoginError;
storedCredId: string;
begin
storedCredId := AuthService.GetCredentialId;
SetBusy(True);
HideNotification;
onBeginOK := procedure(AChallenge, AChallengeToken: string)
begin
DoPasskeyAutoLogin(storedCredId, AChallenge, AChallengeToken);
end;
onBeginErr := procedure(AMsg: string)
begin
SetBusy(False);
ShowNotification('Login Error: ' + AMsg);
end;
AuthService.BeginAuthentication(storedCredId, onBeginOK, onBeginErr);
end;
document.addEventListener('login-passkey', passkeyHandler);
end; end;
end; end;
...@@ -203,6 +170,33 @@ begin ...@@ -203,6 +170,33 @@ begin
AuthService.BeginAuthentication(credentialId, @OnBeginOK, @OnBeginError); AuthService.BeginAuthentication(credentialId, @OnBeginOK, @OnBeginError);
end; end;
procedure TFViewLogin.btnPasskeyLoginClick(Sender: TObject);
var
credId: string;
procedure OnBeginOK(AChallenge, AChallengeToken: string);
begin
DoPasskeyAutoLogin(credId, AChallenge, AChallengeToken);
end;
procedure OnBeginError(AMsg: string);
begin
SetBusy(False);
ShowNotification('Login Error: ' + AMsg);
end;
begin
credId := AuthService.GetCredentialId;
if credId = '' then
begin
ShowNotification('Device not registered. Please restart the app.');
Exit;
end;
SetBusy(True);
HideNotification;
AuthService.BeginAuthentication(credId, @OnBeginOK, @OnBeginError);
end;
procedure TFViewLogin.DoWebAuthnGet(AUser, APassword, AAgency, ACredentialId, procedure TFViewLogin.DoWebAuthnGet(AUser, APassword, AAgency, ACredentialId,
AChallenge, AChallengeToken: string); AChallenge, AChallengeToken: string);
var var
......
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