From f63de9524f5bf2cba753f60fd3a19cda8a2e9907 Mon Sep 17 00:00:00 2001 From: simon lehericey Date: Thu, 24 Nov 2022 12:22:01 +0100 Subject: [PATCH] feat(super_admin): create admin count for super_admin with team_account enabled --- lib/tasks/superadmin.rake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/tasks/superadmin.rake b/lib/tasks/superadmin.rake index b540527a4..9579f3af4 100644 --- a/lib/tasks/superadmin.rake +++ b/lib/tasks/superadmin.rake @@ -18,12 +18,17 @@ namespace :superadmin do email = args[:email] rake_puts "Creating SuperAdmin for #{email}" - a = SuperAdmin.new(email: email, password: Devise.friendly_token) + password = Devise.friendly_token + a = SuperAdmin.new(email:, password:) if a.save rake_puts "#{a.email} created" a.send_reset_password_instructions rake_puts "Password reset instructions sent to #{a.email}" + + user = User.create_or_promote_to_administrateur(email, password) + + user.update!(team_account: true) else rake_puts "An error occured: #{a.errors.full_messages}" end