Commit a30ef51c authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻
Browse files

Merge branch 'production_and_staging_seed_users' into 'develop'

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

See merge request !621
parents 69f541e6 ad3a60f3
Pipeline #18797 passed with stage
in 33 minutes and 26 seconds
...@@ -118,6 +118,7 @@ class User < ApplicationRecord ...@@ -118,6 +118,7 @@ class User < ApplicationRecord
email: email, password: Devise.friendly_token, role: role email: email, password: Devise.friendly_token, role: role
) )
new_user.save! && new_user.send_reset_password_instructions new_user.save! && new_user.send_reset_password_instructions
new_user
end end
def self.new_volunteer(volunteer) def self.new_volunteer(volunteer)
......
...@@ -8,6 +8,30 @@ namespace :setup do ...@@ -8,6 +8,30 @@ namespace :setup do
end end
end end
desc 'Create staging servers initial 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(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)' desc 'Create Superadmin account ready to use (no activation needed)'
task superadmin_initialized: :environment do task superadmin_initialized: :environment do
if ENV['email'].present? 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