lib/ddr/auth/user.rb in ddr-models-1.17.1 vs lib/ddr/auth/user.rb in ddr-models-2.0.0.pre.1
- old
+ new
@@ -6,12 +6,10 @@
included do
include Blacklight::User
has_many :events, inverse_of: :user, class_name: "Ddr::Events::Event"
- attr_writer :groups
-
delegate :can, :can?, :cannot, :cannot?, to: :ability
validates_uniqueness_of :username, :case_sensitive => false
validates_format_of :email, with: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/
@@ -45,52 +43,20 @@
def to_s
user_key
end
- def to_agent
- principal_name
+ def agent
+ user_key
end
- alias_method :agent, :to_agent
def ability
- @ability ||= ::Ability.new(self)
+ # warn "[DEPRECATION] `Ddr::Auth::User#ability` is deprecated." \
+ # " In a web context, please use the `current_ability` helper." \
+ # " Otherwise, please use `Ddr::Auth::AbilityFactory.call(user)`" \
+ # " to create an ability instance for the user."
+ @ability ||= AbilityFactory.call(self)
end
-
- def groups
- @groups ||= Groups.build(self)
- end
-
- def member_of?(group)
- if group.is_a? Group
- groups.include?(group)
- else
- member_of?(Group.new(group))
- end
- end
- alias_method :is_member_of?, :member_of?
-
- def authorized_to_act_as_superuser?
- member_of?(Groups::Superusers)
- end
-
- def principal_name
- user_key
- end
- alias_method :name, :principal_name
- alias_method :eppn, :principal_name
-
- def agents
- groups.agents + [agent]
- end
-
- def principals
- groups.map(&:to_s) + [principal_name]
- end
-
- def has_role?(obj, role)
- obj.principal_has_role?(principals, role)
- end
-
+
end
end
end