Sha256: 9bb998a3f1b0000f38638dd24b8f9c4957479271cce3b448726e4aefc93e4c13
Contents?: true
Size: 1.13 KB
Versions: 1
Compression:
Stored size: 1.13 KB
Contents
namespace :adeia do desc "Create the elements and a group with all the privileges" task permissions: :environment do elements = %w(articles adeia/permissions adeia/tokens) + ENV.fetch("elements", []).split(",") owner = Adeia::Group.find_or_create_by!(name: "superadmin") elements.each do |element| element = Adeia::Element.find_or_create_by!(name: element) Adeia::Permission.find_or_create_by!(adeia_element_id: element.id, owner_id: owner.id, owner_type: "Adeia::Group", permission_type: "all_entries", read_right: true, create_right: true, update_right: true, destroy_right: true) end end desc "Add an user to the group with all the privileges" task superuser: :environment do errors = [] errors << "Please provide an `user_id`: `rake adeia:superuser user_id=1`" unless ENV["user_id"].present? group = Adeia::Group.find_by_name("superadmin") errors << "Please first run `rake adeia:permissions`" if group.nil? if errors.empty? Adeia::GroupUser.create!(user_id: ENV["user_id"], adeia_group_id: group.id) else errors.each { |message| puts message } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
adeia-0.5.3 | lib/tasks/init.rake |