diff --git a/Gemfile.lock b/Gemfile.lock index 978839c..0447ffc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -94,7 +94,7 @@ GEM xpath (~> 2.0) climate_control (0.0.3) activesupport (>= 3.0) - cocaine (0.5.5) + cocaine (0.5.7) climate_control (>= 0.0.3, < 1.0) coderay (1.1.0) coffee-script (2.3.0) @@ -144,7 +144,7 @@ GEM mime-types (1.25.1) mini_portile (0.6.2) minitest (5.5.1) - multi_json (1.10.1) + multi_json (1.11.0) nokogiri (1.6.6.2) mini_portile (~> 0.6.0) paperclip (4.2.1) @@ -212,7 +212,7 @@ GEM rspec-mocks (~> 3.2.0) rspec-support (~> 3.2.0) rspec-support (3.2.2) - sass (3.4.12) + sass (3.4.13) sass-rails (5.0.1) railties (>= 4.0.0, < 5.0) sass (~> 3.1) diff --git a/app/controllers/cmtool/application_controller.rb b/app/controllers/cmtool/application_controller.rb index 2a84f74..540495b 100644 --- a/app/controllers/cmtool/application_controller.rb +++ b/app/controllers/cmtool/application_controller.rb @@ -1,6 +1,6 @@ module Cmtool class ApplicationController < ::ApplicationController - before_filter :authenticate_user!, :authorize_user, :check_environment, :set_locale + before_filter :authorize_user, :check_environment, :set_locale layout 'cmtool/application' private @@ -21,6 +21,11 @@ module Cmtool end end + def cmtool_user + defined?(super) ? super : current_user + end + helper_method :cmtool_user + def check_environment @cmtool_warnings ||= [] @cmtool_warnings << 'no_host_specified' unless ( Rails.application.config.action_mailer.default_url_options[:host] rescue false) || diff --git a/app/controllers/cmtool/users_controller.rb b/app/controllers/cmtool/users_controller.rb index 839fc2a..5359f00 100644 --- a/app/controllers/cmtool/users_controller.rb +++ b/app/controllers/cmtool/users_controller.rb @@ -35,10 +35,6 @@ module Cmtool end @user = ::User.find(params[:id]) if @user.update_attributes(user) - if user['password'] - # Sign in after changing current logged in password - sign_in(@user, :bypass => true) if @user == current_user - end redirect_to cmtool.users_path, :notice => I18n.t('cmtool.action.update.successful', :model => ::User.model_name.human) else render :action => 'edit' diff --git a/app/helpers/cmtool/application_helper.rb b/app/helpers/cmtool/application_helper.rb index 6e2bec5..660c71b 100644 --- a/app/helpers/cmtool/application_helper.rb +++ b/app/helpers/cmtool/application_helper.rb @@ -113,6 +113,10 @@ module Cmtool format("%.2f",n) + %w(B KB MB GB TB)[count] end + def cmtool_user + controller.send :cmtool_user + end + def edit_td(obj) content_tag( :td, diff --git a/app/views/cmtool/application/_menu.html.slim b/app/views/cmtool/application/_menu.html.slim index a229b24..0e09742 100644 --- a/app/views/cmtool/application/_menu.html.slim +++ b/app/views/cmtool/application/_menu.html.slim @@ -7,13 +7,13 @@ li.toggle-topbar.menu-icon a href="#" span Menu - - if user_signed_in? + - if cmtool_user.present? section.top-bar-section ul.right li.has-dropdown - a href="#" = current_user.email + a href="#" = cmtool_user.email ul.dropdown - li.log-out= link_to t('helpers.links.logout'), main_app.destroy_user_session_path, method: :delete + li.log-out= link_to t('helpers.links.logout'), main_app.root_path ul.left - Cmtool::Menu.items.each do |menu_item| - if menu_item.group? diff --git a/app/views/cmtool/application/_user_info.html.slim b/app/views/cmtool/application/_user_info.html.slim index d187e98..fcb6cf4 100644 --- a/app/views/cmtool/application/_user_info.html.slim +++ b/app/views/cmtool/application/_user_info.html.slim @@ -1,5 +1,5 @@ #user-info - #user-info-email= link_to current_user.email, cmtool.user_path(current_user) + #user-info-email= link_to cmtool_user.email, cmtool.user_path(current_user) #user-info-sign-in-out class: user_signed_in? ? 'signed-in' : 'signed-out' - if user_signed_in? = link_to t('devise.sessions.sign_out'), cmtool.destroy_user_session_path diff --git a/spec/dummy/app/controllers/application_controller.rb b/spec/dummy/app/controllers/application_controller.rb index f4fcdb2..bffe251 100644 --- a/spec/dummy/app/controllers/application_controller.rb +++ b/spec/dummy/app/controllers/application_controller.rb @@ -4,6 +4,10 @@ class ApplicationController < ActionController::Base private def authorize_cmtool - redirect_to new_user_session_path unless current_user.present? + redirect_to main_app.new_user_session_path unless current_user.present? + end + + def cmtool_user + current_user end end