summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2016-03-02 17:48:49 -0500
committerRobert Speicher <rspeicher@gmail.com>2016-03-04 17:37:57 -0500
commit599a6d78737237e806dcfe0105b8b81dc696b71f (patch)
tree3bf899a3729ffcf36690634cc72e5a09ebf83061 /db
parentec68d673b24687804b1e1aa4c86b2f8fbc9ba7fd (diff)
downloadgitlab-ce-599a6d78737237e806dcfe0105b8b81dc696b71f.tar.gz
Allow the initial admin to set a passwordrs-no-default-credentials
Closes #1980
Diffstat (limited to 'db')
-rw-r--r--db/fixtures/production/001_admin.rb55
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