17296: Merge branch 'master'
[arvados.git] / apps / workbench / app / views / users / welcome.html.erb
index 2842cd8848921f32382bee64e2b1c9bbd35ad27f..92fd6dad4615c1e618663c08e237e786c3f659fd 100644 (file)
@@ -5,10 +5,10 @@ SPDX-License-Identifier: AGPL-3.0 %>
 <% content_for :breadcrumbs do raw '<!-- -->' end %>
 
 <%= javascript_tag do %>
-      async function controller_password_authenticate(event) {
+      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', {
+        fetch('<%= "#{Rails.configuration.Services.Controller.ExternalURL}" %>arvados/v1/users/authenticate', {
           method: 'POST',
 
           headers: {'Content-Type': 'application/json'},
@@ -16,20 +16,24 @@ SPDX-License-Identifier: AGPL-3.0 %>
             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 = `<p>${respj.errors[0]}</p>`;
-          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
+        }).then(function(resp) {
+          if (!resp.ok) {
+            resp.json().then(function(respj) {
+              document.getElementById('login-authenticate-error').innerHTML = "<p>"+respj.errors[0]+"</p>";
+            });
+            return;
+           }
+
+           var redir = document.getElementById('login-return-to').value
+           if (redir.indexOf('?') > 0) {
+             redir += '&'
+           } else {
+             redir += '?'
+           }
+           resp.json().then(function(respj) {
+             document.location = redir + "api_token=v2/" + respj.uuid + "/" + respj.api_token;
+           });
+         });
       }
       function clear_authenticate_error() {
         document.getElementById('login-authenticate-error').innerHTML = "";
@@ -43,18 +47,9 @@ SPDX-License-Identifier: AGPL-3.0 %>
       <%= raw(Rails.configuration.Workbench.WelcomePageHTML) %>
 
       <% case %>
-      <% when Rails.configuration.Login.Google.Enable %>
-      <% when Rails.configuration.Login.OpenIDConnect.Enable %>
-      <% when Rails.configuration.Login.SSO.Enable %>
-        <div class="pull-right">
-          <%= link_to arvados_api_client.arvados_login_url(return_to: request.url), class: "btn btn-primary" do %>
-          Log in to <%= Rails.configuration.Workbench.SiteName %>
-          <i class="fa fa-fw fa-arrow-circle-right"></i>
-          <% end %>
-        </div>
-      <% when Rails.configuration.Login.PAM.Enable %>
-      <% when Rails.configuration.Login.LDAP.Enable %>
-      <% when Rails.configuration.Login.Test.Enable %>
+      <% when Rails.configuration.Login.PAM.Enable,
+              Rails.configuration.Login.LDAP.Enable,
+              Rails.configuration.Login.Test.Enable %>
         <form id="login-form-tag" onsubmit="controller_password_authenticate(event)">
           <p>username <input type="text" class="form-control" name="login-username"
                             value="" id="login-username" style="width: 50%"
@@ -64,8 +59,15 @@ SPDX-License-Identifier: AGPL-3.0 %>
                             oninput="clear_authenticate_error()"></input></p>
         <input type="hidden" name="return_to" value="<%= "#{Rails.configuration.Services.Workbench1.ExternalURL}" %>" id="login-return-to">
         <span style="color: red"><p id="login-authenticate-error"></p></span>
-        <button type="submit" class="btn btn-primary">Login</button>
+        <button type="submit" class="btn btn-primary">Log in</button>
         </form>
+      <% else %>
+        <div class="pull-right">
+          <%= link_to arvados_api_client.arvados_login_url(return_to: request.url), class: "btn btn-primary" do %>
+          Log in to <%= Rails.configuration.Workbench.SiteName %>
+          <i class="fa fa-fw fa-arrow-circle-right"></i>
+          <% end %>
+        </div>
       <% end %>
 
     </div>