Sha256: 2b5b9434d749da5936fae59ff072e64a5fa9415603baf17bcc3bc5be08dc1945

Contents?: true

Size: 792 Bytes

Versions: 35

Compression:

Stored size: 792 Bytes

Contents

# frozen_string_literal: true

# Define a namespace for the task
namespace :import do
  desc 'Imports the legacy user data into the Devise Admin table'
  task admins: :environment do
    CHARS = ('0'..'9').to_a + ('A'..'Z').to_a + ('a'..'z').to_a + (1..9).to_a + ['`', '~', '!', '@', '#', '$', '%', '^', '&', '*']
    password = CHARS.sort_by { rand }.join[0...15]

    LegacyUser.all.each do |legacy|
      u = User.new(
        email: legacy.email,
        first_name: legacy.name.split(' ')[0],
        last_name: legacy.name.split(' ')[1],
        password: password,
        password_confirmation: password,
        admin: legacy.admin,
        designer: legacy.designer,
        content_editor: legacy.content_editor,
        notes: legacy.notes,
      )
      u.save!
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
trusty-cms-5.3.3 lib/tasks/upgrade_to_devise.rake
trusty-cms-5.3.2 lib/tasks/upgrade_to_devise.rake
trusty-cms-5.3.1 lib/tasks/upgrade_to_devise.rake
trusty-cms-5.3 lib/tasks/upgrade_to_devise.rake
trusty-cms-5.2.3 lib/tasks/upgrade_to_devise.rake
trusty-cms-5.2.2 lib/tasks/upgrade_to_devise.rake
trusty-cms-5.2.1 lib/tasks/upgrade_to_devise.rake
trusty-cms-5.2.0 lib/tasks/upgrade_to_devise.rake
trusty-cms-5.1.0 lib/tasks/upgrade_to_devise.rake
trusty-cms-5.0.9 lib/tasks/upgrade_to_devise.rake
trusty-cms-5.0.7 lib/tasks/upgrade_to_devise.rake
trusty-cms-5.0.6 lib/tasks/upgrade_to_devise.rake
trusty-cms-5.0.5 lib/tasks/upgrade_to_devise.rake
trusty-cms-5.0.4 lib/tasks/upgrade_to_devise.rake
trusty-cms-5.0.3 lib/tasks/upgrade_to_devise.rake
trusty-cms-5.0.2 lib/tasks/upgrade_to_devise.rake
trusty-cms-5.0.1 lib/tasks/upgrade_to_devise.rake
trusty-cms-4.3.5 lib/tasks/upgrade_to_devise.rake
trusty-cms-5.0.0 lib/tasks/upgrade_to_devise.rake
trusty-cms-4.3.4 lib/tasks/upgrade_to_devise.rake