From a900901fa7ed5201d0bf34cc4cd559f82ba25aa1 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Fri, 14 May 2021 15:03:46 -0400 Subject: [PATCH] 17499: Adjust formatting. improve error reporting. Arvados-DCO-1.1-Signed-off-by: Peter Amstutz --- .../app/views/users/welcome.html.erb | 54 ++++++++++--------- 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/apps/workbench/app/views/users/welcome.html.erb b/apps/workbench/app/views/users/welcome.html.erb index 36b457af0a..2842cd8848 100644 --- a/apps/workbench/app/views/users/welcome.html.erb +++ b/apps/workbench/app/views/users/welcome.html.erb @@ -7,31 +7,33 @@ SPDX-License-Identifier: AGPL-3.0 %> <%= javascript_tag do %> async function controller_password_authenticate(event) { event.preventDefault() - document.getElementById('login-authenticate-error').innerHTML = ''; - const resp = await fetch('<%= "#{Rails.configuration.Services.Controller.ExternalURL}" %>arvados/v1/users/authenticate', { - method: 'POST', + document.getElementById('login-authenticate-error').innerHTML = ''; + const resp = await fetch('<%= "#{Rails.configuration.Services.Controller.ExternalURL}" %>arvados/v1/users/authenticate', { + method: 'POST', - headers: {'Content-Type': 'application/json'}, - body: JSON.stringify({ - username: document.getElementById('login-username').value, - password: document.getElementById('login-password').value, - }), - }) + headers: {'Content-Type': 'application/json'}, + body: JSON.stringify({ + username: document.getElementById('login-username').value, + password: document.getElementById('login-password').value, + }), + }) if (!resp.ok) { const respj = await resp.json() - document.getElementById('login-authenticate-error').innerHTML = `

${respj.errors[0]}

`; - return - } - var redir = document.getElementById('login-return-to').value - if (redir.indexOf('?') > 0) { - redir += '&' - } else { - redir += '?' - } + document.getElementById('login-authenticate-error').innerHTML = `

${respj.errors[0]}

`; + return + } + var redir = document.getElementById('login-return-to').value + if (redir.indexOf('?') > 0) { + redir += '&' + } else { + redir += '?' + } const respj = await resp.json() - document.location = redir + "api_token=v2/" + respj.uuid + "/" + respj.api_token + document.location = redir + "api_token=v2/" + respj.uuid + "/" + respj.api_token + } + function clear_authenticate_error() { + document.getElementById('login-authenticate-error').innerHTML = ""; } - // document.getElementById('login-form-tag'). <% end %>
@@ -54,11 +56,15 @@ SPDX-License-Identifier: AGPL-3.0 %> <% when Rails.configuration.Login.LDAP.Enable %> <% when Rails.configuration.Login.Test.Enable %>
-

username

-

password

+

username

+

password

" id="login-return-to"> -

- +

+
<% end %> -- 2.30.2