Sha256: 0d28ad7f45d864b1d9e5ab13a66bae22b811e1b27298e9d76b8ef4dcbdf6e226
Contents?: true
Size: 1.83 KB
Versions: 7
Compression:
Stored size: 1.83 KB
Contents
# frozen_string_literal: true require 'active_scaffold/bridges/cancan/cancan_bridge' module EacRailsBase0 module AppBase class Ability include CanCan::Ability def initialize(user) as_action_aliases user ||= ::EacUsersSupport::User.new devise_rules(user) administrator_rules(user) end def devise_confirmation_rules(user) return unless user.new_record? can :create, 'Devise::Confirmation' can :read, 'Devise::Confirmation' end def devise_invitable_rules(user) can :create, 'Devise::Invitation' if user.administrator? can :update, 'Devise::Invitation' if user.new_record? can :create, 'DeviseInvitable::Registration' else can :update, 'DeviseInvitable::Registration' end end def devise_password_rules(user) return unless user.new_record? can :manage, 'Devise::Password' end def devise_registration_rules(user) can :create, 'Devise::Registration' if user.new_record? can :update, 'Devise::Registration' unless user.new_record? end def devise_session_rules(user) can :destroy, 'Devise::Session' unless user.new_record? can :create, 'Devise::Session' end def devise_rules(user) %w[confirmation invitable password registration session].each do |devise_module| send("devise_#{devise_module}_rules", user) end end def administrator_rules(user) return unless user.administrator? can :manage, ::EacUsersSupport::User can :manage, ::Aranha::Address can :manage, ::BrRailties::FederalUnit can :manage, ::BrRailties::Municipality can :manage, ::ScheduledTask can :manage, :eac_rails_base0_mailer end end end end
Version data entries
7 entries across 7 versions & 1 rubygems