Skip to content

Commit

Permalink
Changes after code-review (thanks @paroga)
Browse files Browse the repository at this point in the history
  • Loading branch information
wvengen committed Oct 13, 2018
1 parent 49f5e08 commit 5b7096b
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
20 changes: 10 additions & 10 deletions app/controllers/concerns/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ def authenticate(role = 'any')
# We have an authenticated user, now check role...
# Roles gets the user through his memberships.
hasRole = case role
when "admin" then current_user.role_admin?
when "finance" then current_user.role_finance?
when "article_meta" then current_user.role_article_meta?
when "pickups" then current_user.role_pickups?
when "suppliers" then current_user.role_suppliers?
when "orders" then current_user.role_orders?
when "finance_or_orders" then (current_user.role_finance? || current_user.role_orders?)
when "pickups_or_orders" then (current_user.role_pickups? || current_user.role_orders?)
when "any" then true # no role required
else false # any unknown role will always fail
when 'admin' then current_user.role_admin?
when 'finance' then current_user.role_finance?
when 'article_meta' then current_user.role_article_meta?
when 'pickups' then current_user.role_pickups?
when 'suppliers' then current_user.role_suppliers?
when 'orders' then current_user.role_orders?
when 'finance_or_orders' then (current_user.role_finance? || current_user.role_orders?)
when 'pickups_or_orders' then (current_user.role_pickups? || current_user.role_orders?)
when 'any' then true # no role required
else false # any unknown role will always fail
end
if hasRole
current_user
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/concerns/locale.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def explicitly_requested_language
end

def user_settings_language
current_user.locale if current_user
current_user&.locale
end

def session_language
Expand All @@ -30,7 +30,7 @@ def default_language
def select_language_according_to_priority
language = explicitly_requested_language || session_language || user_settings_language
language ||= browser_language unless FoodsoftConfig[:ignore_browser_locale]
language.to_sym unless language.blank?
language.presence&.to_sym unless language.blank?
end

def available_locales
Expand Down
4 changes: 2 additions & 2 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ class Application < Rails::Application
config.assets.precompile += [ 'vendor/assets/javascripts/*.js' ]

# CORS for API
config.middleware.insert_before 0, "Rack::Cors" do
config.middleware.insert_before 0, 'Rack::Cors' do
allow do
origins '*'
# this restricts Foodsoft scopes to certain characters - let's discuss it when it becomes an actual problem
resource %r{\A/[-a-zA-Z0-9_]+/api/v1/}, :headers => :any, :methods => :any
resource %r{\A/[-a-zA-Z0-9_]+/api/v1/}, headers: :any, methods: :any
end
end
end
Expand Down
1 change: 1 addition & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,7 @@ de:
use_wiki: Wiki verwenden
webstats_tracking_code: Code für Websiteanalysetool
tabs:
applications: Apps
foodcoop: Foodcoop
language: Sprache
layout: Layout
Expand Down

0 comments on commit 5b7096b

Please sign in to comment.