Verified Commit 94b2bcaa authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻
Browse files

rake task that creates users, sends password reset email, and initializes bulk...

rake task that creates users, sends password reset email, and initializes bulk contact profile for them
parent a5ff5091
Pipeline #18761 failed with stage
in 37 minutes
......@@ -118,6 +118,7 @@ class User < ApplicationRecord
email: email, password: Devise.friendly_token, role: role
)
new_user.save! && new_user.send_reset_password_instructions
new_user
end
def self.new_volunteer(volunteer)
......
......@@ -8,6 +8,31 @@ namespace :setup do
end
end
desc 'Create staging initial superadmin users'
task staging_user_init: :environment do
[
'superadmin@example.com', 'jeannine.stauffer@aoz.ch', 'emi@panter.ch',
'zaida.haener@aoz.ch', 'zsolt@decoding.io', 'seb@panter.ch', 'anna.scheu@uzh.ch'
].each { |email| create_bulk_user(email, 'superadmin') }
[
'sozialarbeiterin@aoz.ch', 'seb+sozialarbeiter@panter.ch'
].each { |email| create_bulk_user(email, 'social_worker') }
[
'department_manager@example.com', 'seb+fwverantwortlich@panter.ch',
'standortverantwortliche@aoz.ch'
].each { |email| create_bulk_user(email, 'department_manager') }
end
def create_bulk_user(email, role)
user = User.create_user_and_send_password_reset email: email, role: role
user.build_profile
user.profile.build_contact
user.profile.contact.assign_attributes(first_name: email, last_name: email,
street: 'example_street', postal_code: '8000', primary_email: email,
primary_phone: '000000')
user.save!
end
desc 'Create Superadmin account ready to use (no activation needed)'
task superadmin_initialized: :environment do
if ENV['email'].present?
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment