Method: Symphonia::ControllerExtensions#authorize

Defined in:
lib/symphonia/controller_extensions.rb

#authorizeObject

Raises:

  • (Unauthorized)


168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# File 'lib/symphonia/controller_extensions.rb', line 168

def authorize
  if Symphonia::User.current.authorize?(controller_name, action_name)
    return true
  else
    if Symphonia::User.current.logged_in?
      raise Unauthorized
    else
      respond_to do |format|
        format.html do
          return redirect_to(symphonia.(back_url: request.path), error: t(:text_error_login_required))
        end
        format.any { return head 401 }
      end
    end
  end
  raise Unauthorized
end