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