Commit cbd0f858 by Michael Brachmann

fixes

parent ecc88919
......@@ -109,6 +109,18 @@ object FViewLogin: TFViewLogin
DisplayText = 'BUF - Buffalo Police Department'
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
Connection = DMConnection.AuthConnection
Left = 492
......
......@@ -15,12 +15,14 @@ type
edtPassword: TWebEdit;
btnShowPassword: TWebButton;
btnLogin: TWebButton;
btnPasskeyLogin: TWebButton;
pnlMessage: TWebPanel;
lblMessage: TWebLabel;
btnCloseNotification: TWebButton;
XDataWebClient: TXDataWebClient;
lucbAgency: TWebLookupComboBox;
procedure btnLoginClick(Sender: TObject);
procedure btnPasskeyLoginClick(Sender: TObject);
procedure btnShowPasswordClick(Sender: TObject);
procedure btnCloseNotificationClick(Sender: TObject);
procedure WebFormCreate(Sender: TObject);
......@@ -77,8 +79,6 @@ var
credId: string;
procedure OnDeviceUser(AUsername, AAgency: string);
var
passkeyHandler: TJSRawEventHandler;
begin
FAutoUsername := AUsername;
FAutoAgency := AAgency;
......@@ -91,16 +91,8 @@ var
if (autoSection) autoSection.classList.remove('d-none');
if (manualSection) manualSection.classList.add('d-none');
if (lbl) lbl.textContent = AUsername;
end;
// Wire passkey button and "use different account" link via JS
asm
var btn = document.getElementById('view.login.btnpasskeylogin');
if (btn) {
btn.addEventListener('click', function() {
document.dispatchEvent(new CustomEvent('login-passkey'));
});
}
// "Use a different account" — pure JS show/hide
var lnk = document.getElementById('view.login.switchmanual');
if (lnk) {
lnk.addEventListener('click', function(e) {
......@@ -110,31 +102,6 @@ var
});
}
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;
......@@ -203,6 +170,33 @@ begin
AuthService.BeginAuthentication(credentialId, @OnBeginOK, @OnBeginError);
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,
AChallenge, AChallengeToken: string);
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