Handling bug http://bugs.joindiaspora.com/issues/767
Added email argument to task, warn and replace if address resolves to an invalid user@domain one.
This commit is contained in:
parent
3338397822
commit
607fea6722
2 changed files with 13 additions and 5 deletions
|
|
@ -26,8 +26,16 @@ def read_password
|
||||||
end
|
end
|
||||||
|
|
||||||
username = (ARGS[:username] || 'admin').dup
|
username = (ARGS[:username] || 'admin').dup
|
||||||
email = ARGS[:email] || "#{username}@#{AppConfig[:pod_uri].host}"
|
|
||||||
password = ARGS[:password] || read_password
|
password = ARGS[:password] || read_password
|
||||||
|
email = ARGS[:email] || "#{username}@#{AppConfig[:pod_uri].host}"
|
||||||
|
if email =~ /localhost$/
|
||||||
|
puts "WARNING: localhost will not validate as an email domain"
|
||||||
|
puts "\tupdate your email address, if you require email notifications for this account"
|
||||||
|
puts "\trake db:first_user[username,password,email]"
|
||||||
|
puts "\trake db:add_user[username,password]"
|
||||||
|
puts "\tor modify your data store"
|
||||||
|
email = 'username@example.com'
|
||||||
|
end
|
||||||
|
|
||||||
user = User.build(:email => email,
|
user = User.build(:email => email,
|
||||||
:username => username,
|
:username => username,
|
||||||
|
|
@ -46,7 +54,7 @@ user.valid?
|
||||||
errors = user.errors
|
errors = user.errors
|
||||||
errors.delete :person
|
errors.delete :person
|
||||||
if errors.size > 0
|
if errors.size > 0
|
||||||
raise "Error(s) creating user #{username}: #{errors.full_messages.to_s}"
|
raise "Error(s) creating user #{username} / #{email}: #{errors.full_messages.to_s}"
|
||||||
end
|
end
|
||||||
|
|
||||||
user.save
|
user.save
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ namespace :db do
|
||||||
create
|
create
|
||||||
end
|
end
|
||||||
|
|
||||||
task :first_user, :username, :password do |t, args|
|
task :first_user, :username, :password, :email do |t, args|
|
||||||
puts "Setting up first user in #{Rails.env} database"
|
puts "Setting up first user in #{Rails.env} database"
|
||||||
ARGS = args
|
ARGS = args
|
||||||
require File.dirname(__FILE__) + '/../../db/seeds/add_user'
|
require File.dirname(__FILE__) + '/../../db/seeds/add_user'
|
||||||
|
|
@ -60,9 +60,9 @@ namespace :db do
|
||||||
end
|
end
|
||||||
|
|
||||||
desc "Purge database and then add the first user"
|
desc "Purge database and then add the first user"
|
||||||
task :first_user, :username, :password do |t, args|
|
task :first_user, :username, :password, :email do |t, args|
|
||||||
Rake::Task['db:purge'].invoke
|
Rake::Task['db:purge'].invoke
|
||||||
Rake::Task['db:seed:first_user'].invoke(args[:username], args[:password])
|
Rake::Task['db:seed:first_user'].invoke(args[:username], args[:password], args[:email])
|
||||||
end
|
end
|
||||||
task :first_user => :environment
|
task :first_user => :environment
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue