Sha256: 249b5d95e40dae2a4a2bddbc51c62fbba4d1fbdea977c652ee4f20cc59f7a27a

Contents?: true

Size: 1.01 KB

Versions: 31

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

namespace :decidim_system do
  desc "Create a new system admin"
  task create_admin: :environment do
    puts "Please, provide the following attributes to create a new system admin#{" (currently there are existing system admins)" if Decidim::System::Admin.exists?}:"
    email = prompt("email", hidden: false)
    password = prompt("Password")
    password_confirmation = prompt("Password confirmation")

    admin = Decidim::System::Admin.new(email: email, password: password, password_confirmation: password_confirmation)

    if admin.valid?
      admin.save!
      puts("System admin created successfully")
    else
      puts("Some errors prevented creation of admin:")
      admin.errors.full_messages.uniq.each do |message|
        puts "  * #{message}"
      end
    end
  end
end

def prompt(attribute, hidden: true)
  print("#{attribute}: ")
  input = if hidden
            $stdin.noecho(&:gets).chomp
          else
            $stdin.gets.chomp
          end
  print("\n") if hidden
  input
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
decidim-system-0.27.9 lib/tasks/decidim_system.rake
decidim-system-0.27.8 lib/tasks/decidim_system.rake
decidim-system-0.27.7 lib/tasks/decidim_system.rake
decidim-system-0.27.6 lib/tasks/decidim_system.rake
decidim-system-0.26.10 lib/tasks/decidim_system.rake
decidim-system-0.26.9 lib/tasks/decidim_system.rake
decidim-system-0.27.5 lib/tasks/decidim_system.rake
decidim-system-0.26.8 lib/tasks/decidim_system.rake
decidim-system-0.27.4 lib/tasks/decidim_system.rake
decidim-system-0.27.3 lib/tasks/decidim_system.rake
decidim-system-0.26.7 lib/tasks/decidim_system.rake
decidim-system-0.26.5 lib/tasks/decidim_system.rake
decidim-system-0.27.2 lib/tasks/decidim_system.rake
decidim-system-0.27.1 lib/tasks/decidim_system.rake
decidim-system-0.26.4 lib/tasks/decidim_system.rake
decidim-system-0.27.0 lib/tasks/decidim_system.rake
decidim-system-0.26.3 lib/tasks/decidim_system.rake
decidim-system-0.27.0.rc2 lib/tasks/decidim_system.rake
decidim-system-0.27.0.rc1 lib/tasks/decidim_system.rake
decidim-system-0.26.2 lib/tasks/decidim_system.rake