diff options
author | Robert Speicher <rspeicher@gmail.com> | 2016-03-03 01:48:49 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-03-05 01:37:57 +0300 |
commit | 599a6d78737237e806dcfe0105b8b81dc696b71f (patch) | |
tree | 3bf899a3729ffcf36690634cc72e5a09ebf83061 /db/fixtures | |
parent | ec68d673b24687804b1e1aa4c86b2f8fbc9ba7fd (diff) |
Allow the initial admin to set a password
Closes #1980
Diffstat (limited to 'db/fixtures')
-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 |