Sha256: 030b203557bdf93fea00bc0947a1aa6e5249203c4dbb802fa8cc5acceb12fbe1

Contents?: true

Size: 748 Bytes

Versions: 8

Compression:

Stored size: 748 Bytes

Contents

module Saucy
  module AccountAuthorization
    extend ActiveSupport::Concern

    included do
      helper_method :current_account
      include InstanceMethods
    end

    module InstanceMethods
      protected

      def current_account
        ::Account.find_by_url!(params[:account_id])
      end

      def current_project
        ::Project.find(params[:project_id])
      end

      def authorize_admin
        unless current_user.admin_of?(current_account)
          deny_access("You must be an admin to access that page.")
        end
      end

      def authorize_member
        unless current_user.member_of?(current_project)
          deny_access("You do not have permission for this project.")
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
saucy-0.1.8 lib/saucy/account_authorization.rb
saucy-0.1.7 lib/saucy/account_authorization.rb
saucy-0.1.6 lib/saucy/account_authorization.rb
saucy-0.1.5 lib/saucy/account_authorization.rb
saucy-0.1.4 lib/saucy/account_authorization.rb
saucy-0.1.3 lib/saucy/account_authorization.rb
saucy-0.1.2 lib/saucy/account_authorization.rb
saucy-0.1.1 lib/saucy/account_authorization.rb