Skip to content

Commit

Permalink
Merge pull request #2048 from beyonnex-io/bugfix/ui-login-fixes
Browse files Browse the repository at this point in the history
fix enter button submitting wrong button in login dialog
  • Loading branch information
thjaeckle authored Oct 24, 2024
2 parents 91fa9f7 + 221334c commit 12a5f32
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
21 changes: 14 additions & 7 deletions ui/modules/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,23 +299,26 @@ 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();
if (devopsToken) {
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();
if (devopsOidcToken) {
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';
Expand All @@ -329,30 +332,34 @@ 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();
if (mainToken) {
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();
if (mainOidcToken) {
authHeaderKey = 'Authorization';
authHeaderValue = 'Bearer ' + mainOidcToken;
} else {
showError('SSO (Bearer) token missing')
showError('SSO (Bearer) token missing');
document.getElementById('authorize').click();
}
} else {
authHeaderKey = 'Authorization';
Expand Down
8 changes: 4 additions & 4 deletions ui/modules/environments/authorization.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ <h5>Main authentication</h5>
<label for="oidcProvider" class="input-group-text"><small>SSO provider</small></label>
<select class="form-select form-select-sm me-2" id="oidcProvider"></select>
<input type="hidden" class="form-control form-control-sm" id="oidcBearer" name="oidcBearer" />
<button class="btn btn-outline-secondary btn-sm" id="main-oidc-login" data-bs-dismiss="modal">Login</button>
<button class="btn btn-outline-secondary btn-sm" id="main-oidc-logout" data-bs-dismiss="modal">Logout</button>
<button type="button" class="btn btn-outline-secondary btn-sm" id="main-oidc-login" data-bs-dismiss="modal">Login</button>
<button type="button" class="btn btn-outline-secondary btn-sm" id="main-oidc-logout" data-bs-dismiss="modal">Logout</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -94,8 +94,8 @@ <h5>DevOps authentication</h5>
<label for="devOpsOidcProvider" class="input-group-text"><small>SSO provider</small></label>
<select class="form-select form-select-sm me-2" id="devOpsOidcProvider"></select>
<input type="hidden" class="form-control form-control-sm" id="oidcBearerDevOps" name="oidcBearerDevOps" />
<button class="btn btn-outline-secondary btn-sm" id="devops-oidc-login" data-bs-dismiss="modal">Login</button>
<button class="btn btn-outline-secondary btn-sm" id="devops-oidc-logout" data-bs-dismiss="modal">Logout</button>
<button type="button" class="btn btn-outline-secondary btn-sm" id="devops-oidc-login" data-bs-dismiss="modal">Login</button>
<button type="button" class="btn btn-outline-secondary btn-sm" id="devops-oidc-logout" data-bs-dismiss="modal">Logout</button>
</div>
</div>
</div>
Expand Down

0 comments on commit 12a5f32

Please sign in to comment.