Sha256: 4e902c555ab6e7de6c12676a006965535a9395bf0932b9057e299fdad8835ea2

Contents?: true

Size: 1.44 KB

Versions: 11

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

module Symphonia
  class UserAbility
    include CanCan::Ability

    def initialize(user)
      return unless user.logged_in?

      can :update, User, id: user.id
      can :read, User, id: user.id
      return unless user.admin?

      can :archive, User, status: :active
      can :activate, User, status: :pending
      can :unarchive, User, status: :archived

      can %i[read create update destroy], :all
      # Define abilities for the user here. For example:
      #
      #   return unless user.present?
      #   can :read, :all
      #   return unless user.admin?
      #   can :manage, :all
      #
      # The first argument to `can` is the action you are giving the user
      # permission to do.
      # If you pass :manage it will apply to every action. Other common actions
      # here are :read, :create, :update and :destroy.
      #
      # The second argument is the resource the user can perform the action on.
      # If you pass :all it will apply to every resource. Otherwise pass a Ruby
      # class of the resource.
      #
      # The third argument is an optional hash of conditions to further filter the
      # objects.
      # For example, here the user can only update published articles.
      #
      #   can :update, Article, published: true
      #
      # See the wiki for details:
      # https://github.com/CanCanCommunity/cancancan/blob/develop/docs/define_check_abilities.md
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
symphonia-6.0.6 app/models/symphonia/user_ability.rb
symphonia-6.0.5 app/models/symphonia/user_ability.rb
symphonia-6.0.4 app/models/symphonia/user_ability.rb
symphonia-6.0.2 app/models/symphonia/user_ability.rb
symphonia-6.0.1 app/models/symphonia/user_ability.rb
symphonia-6.0.0 app/models/symphonia/user_ability.rb
symphonia-5.0.6 app/models/symphonia/user_ability.rb
symphonia-5.0.5 app/models/symphonia/user_ability.rb
symphonia-5.0.4 app/models/symphonia/user_ability.rb
symphonia-5.0.3 app/models/symphonia/user_ability.rb
symphonia-5.0.0 app/models/symphonia/user_ability.rb