2872: Make "inactive" and "not logged in" behavior work on all pages, not just dashboard.
authorTom Clegg <tom@curoverse.com>
Fri, 6 Jun 2014 06:49:56 +0000 (02:49 -0400)
committerTom Clegg <tom@curoverse.com>
Fri, 6 Jun 2014 06:49:56 +0000 (02:49 -0400)
apps/workbench/app/controllers/application_controller.rb
apps/workbench/app/controllers/users_controller.rb
apps/workbench/app/views/users/inactive.html.erb [new file with mode: 0644]
apps/workbench/app/views/users/welcome.html.erb
apps/workbench/test/functional/folders_controller_test.rb

index a5034fd895593a8c9e1573e41730bce1f015dc54..64f5c6935d014717cce80e3c7f2b95fc6e64e8db 100644 (file)
@@ -368,8 +368,12 @@ class ApplicationController < ActionController::Base
   end
 
   def thread_with_mandatory_api_token
-    thread_with_api_token do
-      yield
+    thread_with_api_token(true) do
+      if Thread.current[:arvados_api_token]
+        yield
+      else
+        render 'users/welcome'
+      end
     end
   end
 
@@ -403,7 +407,10 @@ class ApplicationController < ActionController::Base
   end
 
   def check_user_agreements
-    if current_user && !current_user.is_active && current_user.is_invited
+    if current_user && !current_user.is_active
+      if not current_user.is_invited
+        return render 'users/inactive'
+      end
       signatures = UserAgreement.signatures
       @signed_ua_uuids = UserAgreement.signatures.map &:head_uuid
       @required_user_agreements = UserAgreement.all.map do |ua|
index 3d8c8530add9aecd27898bc0325bfa44d8be165f..0313de5aa2e7b9559146b9cfca7a6f31b166862d 100644 (file)
@@ -1,6 +1,5 @@
 class UsersController < ApplicationController
   skip_before_filter :find_object_by_uuid, :only => [:welcome, :activity, :storage]
-  skip_around_filter :thread_with_mandatory_api_token, :only => :welcome
   before_filter :ensure_current_user_is_admin, only: [:sudo, :unsetup, :setup]
 
   def welcome
diff --git a/apps/workbench/app/views/users/inactive.html.erb b/apps/workbench/app/views/users/inactive.html.erb
new file mode 100644 (file)
index 0000000..5f825e4
--- /dev/null
@@ -0,0 +1,22 @@
+<% content_for :breadcrumbs do raw '<!-- -->' end %>
+
+<div class="row">
+  <div class="col-sm-8 col-sm-push-4" style="margin-top: 1em">
+    <div class="well clearfix">
+      <%= image_tag "dax.png", style: "width: 147px; height: 197px; max-width: 25%; margin-right: 2em", class: 'pull-left' %>
+
+      <h3>Hi! You're logged in, but...</h3>
+
+      <p>
+
+        Your account is inactive.
+
+      </p><p>
+
+        An administrator must activate your account before you can get
+        any further.
+
+      </p>
+    </div>
+  </div>
+</div>
index 537041e8f8871c45749db7a3e04c2b5f4520f333..9cacebda02971ccdbff2d28569dd7a6d55e35cff 100644 (file)
@@ -1,23 +1,38 @@
 <% content_for :breadcrumbs do raw '<!-- -->' end %>
 
-<%= image_tag "dax.png", style: "float: left; max-width: 25%; margin-right: 2em" %>
-<h1>Hi there!  Please log in to use <%= Rails.configuration.site_name %>.</h1>
-<div class="row-fluid">
-  <div class="col span8" style="margin-top: 1em">
+<div class="row">
+  <div class="col-sm-8 col-sm-push-4" style="margin-top: 1em">
     <div class="well clearfix">
-      <p>When you click on the button below you will be taken to a Google sign-in page.
-       After entering your information, you will be redirected back to <%= Rails.configuration.site_name %>
-       If you have never used <%= Rails.configuration.site_name %> before, logging in for the first
-       time will also create a new user account. <%= Rails.configuration.site_name %> uses your name and
-       email address from Google services only for identification, and can not access any personal information
-  beyond that.
-  </p>
+      <%= image_tag "dax.png", style: "width: 147px; height: 197px; max-width: 25%; margin-right: 2em", class: 'pull-left' %>
+
+      <h3>Please log in.</h3>
+
+      <p>
+
+        The "Log in" button below will show you a Google sign-in page.
+       After you assure Google that you want to log in here with your
+       Google account, you will be redirected back here to
+       <%= Rails.configuration.site_name %>.
+
+      </p><p>
+
+       If you have never used <%= Rails.configuration.site_name %>
+       before, logging in for the first time will automatically
+       create a new account.
+
+      </p><p>
+
+        <i><%= Rails.configuration.site_name %> uses your name and
+       email address only for identification, and does not retrieve
+       any other personal information from Google.</i>
+
+      </p>
       <p>
-       <a  class="pull-right btn btn-primary" href="<%= arvados_api_client.arvados_login_url(return_to: request.url) %>">
-         Click here to log in to <%= Rails.configuration.site_name %> with a Google account</a>
+       <%= link_to arvados_api_client.arvados_login_url(return_to: request.url), class: "pull-right btn btn-primary" do %>
+          Log in to <%= Rails.configuration.site_name %>
+          <i class="fa fa-fw fa-arrow-circle-right"></i>
+        <% end %>
       </p>
     </div>
   </div>
 </div>
-
-
index 2e06ccac31815a38d555a9848604ffcc6d394c10..8459278fafd5ef315829a258c6460250a959ca5f 100644 (file)
@@ -1,7 +1,12 @@
 require 'test_helper'
 
 class FoldersControllerTest < ActionController::TestCase
-  # test "the truth" do
-  #   assert true
-  # end
+  test "inactive user is asked to sign user agreements on front page" do
+    get :index, {}, session_for(:inactive)
+    assert_response :success
+    assert_not_empty assigns(:required_user_agreements),
+    "Inactive user did not have required_user_agreements"
+    assert_template 'user_agreements/index',
+    "Inactive user was not presented with a user agreement at the front page"
+  end
 end