Run rubocop --fix-layout and remove encoding comments

This commit is contained in:
Patrick Gansterer 2021-03-01 15:27:26 +01:00
parent fa63e6e81d
commit ea2862fdef
283 changed files with 1164 additions and 1969 deletions

View file

@ -24,7 +24,7 @@ module Concerns::Auth
def login(user)
session[:user_id] = user.id
session[:scope] = FoodsoftConfig.scope # Save scope in session to not allow switching between foodcoops with one account
session[:scope] = FoodsoftConfig.scope # Save scope in session to not allow switching between foodcoops with one account
session[:locale] = user.locale
end
@ -56,18 +56,18 @@ module Concerns::Auth
# 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_invoices' then (current_user.role_finance? || current_user.role_invoices?)
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
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_invoices' then (current_user.role_finance? || current_user.role_invoices?)
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
else
@ -137,6 +137,7 @@ module Concerns::Auth
# @see https://github.com/doorkeeper-gem/doorkeeper/issues/71#issuecomment-5471317
def expire_access_tokens
return unless @current_user
Doorkeeper::AccessToken.transaction do
token_scope = Doorkeeper::AccessToken.where(revoked_at: nil, resource_owner_id: @current_user.id)
token_scope.each do |token|
@ -146,8 +147,7 @@ module Concerns::Auth
end
# Redirect to the login page, used in authenticate, plugins can override this.
def redirect_to_login(options={})
def redirect_to_login(options = {})
redirect_to login_url, options
end
end

View file

@ -36,7 +36,7 @@ module Concerns::AuthApi
# Make sure that at least one the given OAuth scopes is valid for the current user's permissions.
# @raise Api::Errors::PermissionsRequired
def doorkeeper_authorize_roles!(*scopes)
unless scopes.any? {|scope| doorkeeper_scope_permitted?(scope) }
unless scopes.any? { |scope| doorkeeper_scope_permitted?(scope) }
raise Api::Errors::PermissionRequired.new('Forbidden, no permission')
end
end
@ -60,7 +60,7 @@ module Concerns::AuthApi
when 'suppliers' then return current_user.role_suppliers?
when 'group_orders' then return current_user.role_orders?
when 'finance' then return current_user.role_finance?
# please note that offline_access does not belong here, since it is not used for permission checking
# please note that offline_access does not belong here, since it is not used for permission checking
end
case scope

View file

@ -54,5 +54,4 @@ module Concerns::CollectionScope
def ransack_auth_object
nil
end
end

View file

@ -30,7 +30,6 @@ module Concerns::FoodcoopScope
# Always stay in foodcoop url scope
def default_url_options(options = {})
super().merge({foodcoop: FoodsoftConfig.scope})
super().merge({ foodcoop: FoodsoftConfig.scope })
end
end

View file

@ -47,5 +47,4 @@ module Concerns::Locale
locale = session[:locale] = ::I18n.locale
logger.info("Set locale to #{locale}")
end
end

View file

@ -9,9 +9,8 @@ module Concerns::SendOrderPdf
when 'articles' then OrderByArticles
when 'fax' then OrderFax
when 'matrix' then OrderMatrix
end
end
pdf = klass.new order
send_data pdf.to_pdf, filename: pdf.filename, type: 'application/pdf'
end
end