def deny_access(exception)
if current_user
- raise "Access denied on #{exception.action} #{exception.subject.inspect}"
- # ...
+ set_locale
+ report_error t("oauth.permissions.missing"), :forbidden
else
require_user
end
class UserPreferencesController < ApplicationController
skip_before_action :verify_authenticity_token
before_action :authorize
- before_action :require_allow_read_prefs, :only => [:read_one, :read]
- before_action :require_allow_write_prefs, :except => [:read_one, :read]
+
+ authorize_resource
+
around_action :api_call_handle_error
##
can [:create, :edit, :comment, :subscribe, :unsubscribe], DiaryEntry
+ 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)
+
if user.administrator?
can [:hide, :hidecomment], [DiaryEntry, DiaryComment]
end