diff options
Diffstat (limited to 'db/fixtures/production/001_admin.rb')
-rw-r--r-- | db/fixtures/production/001_admin.rb | 55 |
1 files changed, 30 insertions, 25 deletions
diff --git a/db/fixtures/production/001_admin.rb b/db/fixtures/production/001_admin.rb index 308b0528c9b..78746c83225 100644 --- a/db/fixtures/production/001_admin.rb +++ b/db/fixtures/production/001_admin.rb @@ -1,33 +1,38 @@ +user_args = { + email: ENV['GITLAB_ROOT_EMAIL'].presence || 'admin@example.com', + name: 'Administrator', + username: 'root', + admin: true +} + if ENV['GITLAB_ROOT_PASSWORD'].blank? - password = '5iveL!fe' - expire_time = Time.now + user_args[:password_automatically_set] = true + user_args[:force_random_password] = true else - password = ENV['GITLAB_ROOT_PASSWORD'] - expire_time = nil + user_args[:password] = ENV['GITLAB_ROOT_PASSWORD'] end -email = ENV['GITLAB_ROOT_EMAIL'].presence || 'admin@example.com' - -admin = User.create( - email: email, - name: "Administrator", - username: 'root', - password: password, - password_expires_at: expire_time, - theme_id: Gitlab::Themes::APPLICATION_DEFAULT - -) +user = User.new(user_args) +user.skip_confirmation! -admin.projects_limit = 10000 -admin.admin = true -admin.save! -admin.confirm +if user.save + puts "Administrator account created:".green + puts + puts "login: root".green -if admin.valid? -puts %Q[ -Administrator account created: + if user_args.key?(:password) + puts "password: #{user_args[:password]}".green + else + puts "password: You'll be prompted to create one on your first visit.".green + end + puts +else + puts "Could not create the default administrator account:".red + puts + user.errors.full_messages.map do |message| + puts "--> #{message}".red + end + puts -login.........root -password......#{password} -] + exit 1 end |