Make rubocop happy
This commit is contained in:
parent
91fc65a2e3
commit
25256a4849
7 changed files with 8 additions and 17 deletions
|
@ -478,7 +478,7 @@ class ApplicationController < ActionController::Base
|
|||
Capability.new(current_user, current_token)
|
||||
end
|
||||
|
||||
def deny_access(exception)
|
||||
def deny_access(_exception)
|
||||
if current_user
|
||||
set_locale
|
||||
report_error t("oauth.permissions.missing"), :forbidden
|
||||
|
|
|
@ -11,7 +11,6 @@ class DiaryEntryController < ApplicationController
|
|||
before_action :check_database_writable, :only => [:new, :edit, :comment, :hide, :hidecomment, :subscribe, :unsubscribe]
|
||||
before_action :allow_thirdparty_images, :only => [:new, :edit, :list, :view, :comments]
|
||||
|
||||
|
||||
def new
|
||||
@title = t "diary_entry.new.title"
|
||||
|
||||
|
@ -247,7 +246,6 @@ class DiaryEntryController < ApplicationController
|
|||
params.require(:diary_comment).permit(:body)
|
||||
end
|
||||
|
||||
|
||||
##
|
||||
# decide on a location for the diary entry map
|
||||
def set_map_location
|
||||
|
|
|
@ -17,9 +17,7 @@ class Ability
|
|||
|
||||
can [:create, :edit, :comment, :subscribe, :unsubscribe], DiaryEntry
|
||||
|
||||
if user.administrator?
|
||||
can [:hide, :hidecomment], [DiaryEntry, DiaryComment]
|
||||
end
|
||||
can [:hide, :hidecomment], [DiaryEntry, DiaryComment] if user.administrator?
|
||||
end
|
||||
# Define abilities for the passed in user here. For example:
|
||||
#
|
||||
|
|
|
@ -5,15 +5,17 @@ class Capability
|
|||
|
||||
def initialize(user, token)
|
||||
if user
|
||||
can [:read, :read_one], UserPreference if has_capability?(token, :allow_read_prefs)
|
||||
can [:update, :update_one, :delete_one], UserPreference if has_capability?(token, :allow_write_prefs)
|
||||
can [:read, :read_one], UserPreference if capability?(token, :allow_read_prefs)
|
||||
can [:update, :update_one, :delete_one], UserPreference if capability?(token, :allow_write_prefs)
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# If a user provides no tokens, they've authenticated via a non-oauth method
|
||||
# and permission to access to all capabilities is assumed.
|
||||
def has_capability?(token, cap)
|
||||
def capability?(token, cap)
|
||||
token.nil? || token.read_attribute(cap)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue