lib/aptible/rails/controller.rb in aptible-rails-0.4.11 vs lib/aptible/rails/controller.rb in aptible-rails-0.4.12
- old
+ new
@@ -37,11 +37,12 @@
token_subject || session_subject
end
# before_action :set_default_organization
def set_default_organization
- self.current_organization ||=
- Aptible::Auth::Organization.all(token: session_token).first
+ return current_organization if current_organization
+ orgs = Aptible::Auth::Organization.all(token: session_token)
+ self.current_organization = orgs.first if orgs.any?
end
# before_action :authenticate_user
def authenticate_user
redirect_to Aptible::Rails.configuration.login_url unless current_user