Sha256: 067542a7ed91bc361ac8a97eceba1a938721693b7e6631e21056c93d3dcce1c8
Contents?: true
Size: 1.87 KB
Versions: 5
Compression:
Stored size: 1.87 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, ::Aranha::StartPoint can :manage, ::BrRailties::FederalUnit can :manage, ::BrRailties::Municipality can :manage, ::ScheduledTask can :manage, :eac_rails_base0_mailer end end end end
Version data entries
5 entries across 5 versions & 1 rubygems