Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/db
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2016-03-03 01:48:49 +0300
committerRobert Speicher <rspeicher@gmail.com>2016-03-05 01:37:57 +0300
commit599a6d78737237e806dcfe0105b8b81dc696b71f (patch)
tree3bf899a3729ffcf36690634cc72e5a09ebf83061 /db
parentec68d673b24687804b1e1aa4c86b2f8fbc9ba7fd (diff)
Allow the initial admin to set a password
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