Skip to content

Commit

Permalink
Fix central manage login and logout bugs. (#247)
Browse files Browse the repository at this point in the history
* Fix central manage login and logout bugs.

* Miner refactory.

* Codeclimate fixed in application_controller
  • Loading branch information
fabricioalbarnaz authored and andrerpbts committed Sep 13, 2017
1 parent 9a4b217 commit d05e03c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Changelog

## [Unreleased]

### Fixed
- Allowed params to update project via API
- Fix central manage login and logout bugs

### Added
- Don't show projects to guests that he's not member of
Expand Down
12 changes: 9 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class ApplicationController < ActionController::Base
include SidebarController

before_action :authenticate_user!, unless: :devise_controller?
before_action :check_team_presence, unless: :devise_controller?
before_action :check_team_presence, if: :need_check_team?
before_action :set_locale
before_action :set_layout_settings
around_action :user_time_zone, if: :current_user
Expand Down Expand Up @@ -56,8 +56,9 @@ def current_team
helper_method :current_team

def after_sign_in_path_for(resource)
return super if resource.is_a?(AdminUser)
if resource.authy_enabled && resource.authy_id.blank?
return send("#{resource_name}_enable_authy_path")
return public_send("#{resource_name}_enable_authy_path")
end

set_current_team_if_single
Expand All @@ -74,8 +75,9 @@ def check_team_presence

def set_current_team_if_single
user_teams = current_user.teams.not_archived
return if user_teams.size != 1

session[:current_team_slug] = user_teams.first.slug if user_teams.size == 1
session[:current_team_slug] = user_teams.first.slug
end

def must_pundit?
Expand All @@ -87,6 +89,10 @@ def set_layout_settings
@layout_settings = @layout_settings_default.dup
end

def need_check_team?
current_user.present? && !devise_controller?
end

def show_recaptcha?
ENV.fetch('ENABLE_RECAPTCHA', false)
end
Expand Down
1 change: 1 addition & 0 deletions config/initializers/active_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#
# Default:
config.default_namespace = :manage

#
# You can customize the settings for each namespace by using
# a namespace block. For example, to change the site title
Expand Down
2 changes: 1 addition & 1 deletion config/initializers/devise.rb
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@

# Set this configuration to false if you want /users/sign_out to sign out
# only the current scope. By default, Devise signs out all scopes.
# config.sign_out_all_scopes = true
config.sign_out_all_scopes = false

# ==> Navigation configuration
# Lists the formats that should be treated as navigational. Formats like
Expand Down

0 comments on commit d05e03c

Please sign in to comment.