1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-29 18:52:22 +01:00

[bug] db:seed throw an error about admin creation

This commit is contained in:
Sylvain 2017-06-14 17:28:36 +02:00
parent 42d2c2ee31
commit 0d82186a78
2 changed files with 3 additions and 2 deletions

View File

@ -2,6 +2,7 @@
## next release
- Fix a bug: when upgrading from version < 2.5.0, `db:seed` will throw an error if ADMIN_EMAIL does not match any admin in database
- Fix a bug: hide spaces in public calendar when module is disabled
- Fix a bug: confirmation message not shown after admin creation
- add task `rake fablab:get_incoherent_invoice` allow find the invoices incoherent

View File

@ -82,8 +82,8 @@ if Group.count == 0
])
end
# Create the admin if it does not exist yet
if User.find_by(email: Rails.application.secrets.admin_email).nil?
# Create the default admin if none exists yet
if Role.find_by(name: 'admin').users.count === 0
admin = User.new(username: 'admin', email: Rails.application.secrets.admin_email, password: Rails.application.secrets.admin_password, password_confirmation: Rails.application.secrets.admin_password, group_id: Group.first.id, profile_attributes: {first_name: 'admin', last_name: 'admin', gender: true, phone: '0123456789', birthday: Time.now})
admin.add_role 'admin'
admin.save!