From 221334cf55d1090e5255aa058dbe475a89c40bac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20J=C3=A4ckle?= Date: Thu, 24 Oct 2024 08:05:51 +0200 Subject: [PATCH] fix enter button submitting wrong button in login dialog * directly show login dialog when e.g. "Bearer token missing" error is shown --- ui/modules/api.ts | 21 ++++++++++++++------- ui/modules/environments/authorization.html | 8 ++++---- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/ui/modules/api.ts b/ui/modules/api.ts index a7fef68b3d..aee7f2199c 100644 --- a/ui/modules/api.ts +++ b/ui/modules/api.ts @@ -299,7 +299,8 @@ export function setAuthHeader(forDevOps: boolean) { authHeaderKey = 'Authorization'; authHeaderValue = 'Basic ' + window.btoa(devopsUserPass); } else { - showError('DevOps Username/password missing') + showError('DevOps Username/password missing'); + document.getElementById('authorize').click(); } } else if (devopsAuthMethod === AuthMethod.bearer) { let devopsToken = devopsBearerToken(); @@ -307,7 +308,8 @@ export function setAuthHeader(forDevOps: boolean) { authHeaderKey = 'Authorization'; authHeaderValue = 'Bearer ' + devopsToken; } else { - showError('DevOps Bearer token missing') + showError('DevOps Bearer token missing'); + document.getElementById('authorize').click(); } } else if (devopsAuthMethod === AuthMethod.oidc) { let devopsOidcToken = devopsOidcBearerToken(); @@ -315,7 +317,8 @@ export function setAuthHeader(forDevOps: boolean) { authHeaderKey = 'Authorization'; authHeaderValue = 'Bearer ' + devopsOidcToken; } else { - showError('DevOps SSO (Bearer) token missing') + showError('DevOps SSO (Bearer) token missing'); + document.getElementById('authorize').click(); } } else { authHeaderKey = 'Authorization'; @@ -329,14 +332,16 @@ export function setAuthHeader(forDevOps: boolean) { authHeaderKey = 'Authorization'; authHeaderValue = 'Basic ' + window.btoa(mainUserPass); } else { - showError('Username/password missing') + showError('Username/password missing'); + document.getElementById('authorize').click(); } } else if (mainAuthMethod === AuthMethod.pre) { if (environment.authSettings.main.pre.dittoPreAuthenticatedUsername) { authHeaderKey = 'x-ditto-pre-authenticated'; authHeaderValue = environment.authSettings.main.pre.dittoPreAuthenticatedUsername; } else { - showError('Pre-Authenticated username missing') + showError('Pre-Authenticated username missing'); + document.getElementById('authorize').click(); } } else if (mainAuthMethod === AuthMethod.bearer) { let mainToken = mainBearerToken(); @@ -344,7 +349,8 @@ export function setAuthHeader(forDevOps: boolean) { authHeaderKey = 'Authorization'; authHeaderValue = 'Bearer ' + mainToken; } else { - showError('Bearer token missing') + showError('Bearer token missing'); + document.getElementById('authorize').click(); } } else if (mainAuthMethod === AuthMethod.oidc) { let mainOidcToken = mainOidcBearerToken(); @@ -352,7 +358,8 @@ export function setAuthHeader(forDevOps: boolean) { authHeaderKey = 'Authorization'; authHeaderValue = 'Bearer ' + mainOidcToken; } else { - showError('SSO (Bearer) token missing') + showError('SSO (Bearer) token missing'); + document.getElementById('authorize').click(); } } else { authHeaderKey = 'Authorization'; diff --git a/ui/modules/environments/authorization.html b/ui/modules/environments/authorization.html index 256d7cac41..a33d805c1b 100644 --- a/ui/modules/environments/authorization.html +++ b/ui/modules/environments/authorization.html @@ -31,8 +31,8 @@
Main authentication
- - + + @@ -94,8 +94,8 @@
DevOps authentication
- - + +