mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-06 06:56:54 +08:00
Merge pull request #247 from Ducz0r/lm-hotfix-blank-current-org
Add check in application controller to always set current org if nil
This commit is contained in:
commit
eec6b1403d
1 changed files with 10 additions and 0 deletions
|
@ -8,6 +8,7 @@ class ApplicationController < ActionController::Base
|
|||
before_action :authenticate_user!
|
||||
helper_method :current_organization
|
||||
before_action :generate_intro_tutorial, if: :is_current_page_root?
|
||||
before_action :update_current_organization, if: :user_signed_in?
|
||||
around_action :set_time_zone, if: :current_user
|
||||
layout 'main'
|
||||
|
||||
|
@ -81,6 +82,15 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
def update_current_organization
|
||||
if current_user.current_organization_id.blank? &&
|
||||
current_user.organizations.count > 0
|
||||
current_user.update(
|
||||
current_organization_id: current_user.organizations.first.id
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
# With this Devise callback user is redirected directly to sign in page instead
|
||||
# of to root path. Therefore notification for sign out is displayed.
|
||||
def after_sign_out_path_for(resource_or_scope)
|
||||
|
|
Loading…
Reference in a new issue