Sha256: a51339057b09e65285f0b83f647b7e6b75e45aeb02c108598c04b9097d3be0fe
Contents?: true
Size: 1016 Bytes
Versions: 9
Compression:
Stored size: 1016 Bytes
Contents
require 'highline/import' def default_email 'comable@example.com' end def default_password 'password' end def ask_admin_email if ENV['ADMIN_EMAIL'] ENV['ADMIN_EMAIL'] else ask("Email [#{default_email}]: ") do |q| q.echo = true q.whitespace = :strip end end.presence || default_email end def ask_admin_password if ENV['ADMIN_PASSWORD'] ENV['ADMIN_PASSWORD'] else ask("Password [#{default_password}]: ") do |q| q.echo = false q.whitespace = :strip end end.presence || default_password end def create_admin_user email = ask_admin_email password = ask_admin_password if Comable::User.where(email: email).exists? puts "WARNING: The email address has already existed: #{email}" else Comable::User.with_role(:admin).new do |obj| obj.email = email obj.password = password end.save! end end if Comable::User.with_role(:admin).exists? puts 'Admin user has already been previously created.' else create_admin_user end
Version data entries
9 entries across 9 versions & 2 rubygems