before_update :maybe_update_modified_by_fields
validate :ensure_serialized_attribute_type
+ has_many :permissions, :foreign_key => :head_uuid, :class_name => 'Link', :primary_key => :uuid, :conditions => "link_class = 'permission'"
+
class PermissionDeniedError < StandardError
end
end
def permission_to_create
- current_user
+ current_user.andand.is_active
end
def ensure_permission_to_update
logger.warn "Anonymous user tried to update #{self.class.to_s} #{self.uuid_was}"
return false
end
+ if !current_user.is_active
+ logger.warn "Inactive user #{current_user.uuid} tried to update #{self.class.to_s} #{self.uuid_was}"
+ return false
+ end
if self.uuid_changed?
logger.warn "User #{current_user.uuid} tried to change uuid of #{self.class.to_s} #{self.uuid_was} to #{self.uuid}"
return false