1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-26 20:54:21 +01:00

extracts first admin created email and password into environment variables

This commit is contained in:
Nicolas Florentin 2017-04-03 15:48:32 +02:00
parent 77a24f14c6
commit 004e74e13e
4 changed files with 18 additions and 4 deletions

View File

@ -277,6 +277,10 @@ Maximum size (in bytes) allowed for image uploaded on the platform.
This parameter concerns events, plans, user's avatars, projects and steps of projects. This parameter concerns events, plans, user's avatars, projects and steps of projects.
If this parameter is not specified the maximum size allowed will be 2MB. If this parameter is not specified the maximum size allowed will be 2MB.
ADMIN_EMAIL, ADMIN_PASSWORD
Credentials for the first admin user created when seeding the project.
Settings related to Open Projects Settings related to Open Projects
See the [Open Projects](#open-projects) section for a detailed description of these parameters. See the [Open Projects](#open-projects) section for a detailed description of these parameters.

View File

@ -63,3 +63,6 @@ ALLOWED_MIME_TYPES: application/pdf application/postscript application/illustrat
# 10485760 = 10 megabytes # 10485760 = 10 megabytes
MAX_IMAGE_SIZE: '10485760' MAX_IMAGE_SIZE: '10485760'
ADMIN_EMAIL: ''
ADMIN_PASSWORD: ''

View File

@ -41,6 +41,8 @@ development:
facebook_app_id: <%= ENV["FACEBOOK_APP_ID"] %> facebook_app_id: <%= ENV["FACEBOOK_APP_ID"] %>
elaticsearch_host: <%= ENV["ELASTICSEARCH_HOST"] %> elaticsearch_host: <%= ENV["ELASTICSEARCH_HOST"] %>
max_image_size: <%= ENV["MAX_IMAGE_SIZE"] %> max_image_size: <%= ENV["MAX_IMAGE_SIZE"] %>
admin_email: <%= ENV["ADMIN_EMAIL"] %>
admin_password: <%= ENV["ADMIN_PASSWORD"] %>
test: test:
secret_key_base: 83daf5e7b80d990f037407bab78dff9904aaf3c195a50f84fa8695a22287e707dfbd9524b403b1dcf116ae1d8c06844c3d7ed942564e5b46be6ae3ead93a9d30 secret_key_base: 83daf5e7b80d990f037407bab78dff9904aaf3c195a50f84fa8695a22287e707dfbd9524b403b1dcf116ae1d8c06844c3d7ed942564e5b46be6ae3ead93a9d30
@ -73,6 +75,8 @@ test:
facebook_app_id: <%= ENV["FACEBOOK_APP_ID"] %> facebook_app_id: <%= ENV["FACEBOOK_APP_ID"] %>
elaticsearch_host: localhost elaticsearch_host: localhost
max_image_size: <%= ENV["MAX_IMAGE_SIZE"] %> max_image_size: <%= ENV["MAX_IMAGE_SIZE"] %>
admin_email: <%= ENV["ADMIN_EMAIL"] %>
admin_password: <%= ENV["ADMIN_PASSWORD"] %>
staging: staging:
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@ -110,6 +114,8 @@ staging:
facebook_app_id: <%= ENV["FACEBOOK_APP_ID"] %> facebook_app_id: <%= ENV["FACEBOOK_APP_ID"] %>
elaticsearch_host: <%= ENV["ELASTICSEARCH_HOST"] %> elaticsearch_host: <%= ENV["ELASTICSEARCH_HOST"] %>
max_image_size: <%= ENV["MAX_IMAGE_SIZE"] %> max_image_size: <%= ENV["MAX_IMAGE_SIZE"] %>
admin_email: <%= ENV["ADMIN_EMAIL"] %>
admin_password: <%= ENV["ADMIN_PASSWORD"] %>
# Do not keep production secrets in the repository, # Do not keep production secrets in the repository,
# instead read values from the environment. # instead read values from the environment.
@ -150,3 +156,5 @@ production:
facebook_app_id: <%= ENV["FACEBOOK_APP_ID"] %> facebook_app_id: <%= ENV["FACEBOOK_APP_ID"] %>
elaticsearch_host: <%= ENV["ELASTICSEARCH_HOST"] %> elaticsearch_host: <%= ENV["ELASTICSEARCH_HOST"] %>
max_image_size: <%= ENV["MAX_IMAGE_SIZE"] %> max_image_size: <%= ENV["MAX_IMAGE_SIZE"] %>
admin_email: <%= ENV["ADMIN_EMAIL"] %>
admin_password: <%= ENV["ADMIN_PASSWORD"] %>

View File

@ -83,11 +83,10 @@ if Group.count == 0
end end
# Create the admin if it does not exist yet # Create the admin if it does not exist yet
if User.find_by(email: 'admin@fab-manager.com').nil? if User.find_by(email: Rails.application.secrets.admin_email).nil?
admin = User.new(username: 'admin', email: 'admin@fab-manager.com', password: 'adminadmin', password_confirmation: 'adminadmin', group_id: Group.first.id, 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})
profile_attributes: {first_name: 'admin', last_name: 'admin', gender: true, phone: '0123456789', birthday: Time.now})
admin.add_role 'admin' admin.add_role 'admin'
admin.save admin.save!
end end
if Component.count == 0 if Component.count == 0