mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 23:30:12 +01:00
Require only stdlib for password reset rake task
This commit is contained in:
parent
1b3543c5de
commit
4a3d5a74e6
3 changed files with 8 additions and 7 deletions
1
Gemfile
1
Gemfile
|
|
@ -31,7 +31,6 @@ gem "htmlentities"
|
||||||
gem "swf_fu"
|
gem "swf_fu"
|
||||||
gem "rails_autolink"
|
gem "rails_autolink"
|
||||||
gem "cache_digests"
|
gem "cache_digests"
|
||||||
gem "highline" # for reset_password rake task
|
|
||||||
|
|
||||||
# To use ActiveModel has_secure_password
|
# To use ActiveModel has_secure_password
|
||||||
gem 'bcrypt-ruby', '~> 3.0.0'
|
gem 'bcrypt-ruby', '~> 3.0.0'
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,6 @@ GEM
|
||||||
ffi (1.9.3)
|
ffi (1.9.3)
|
||||||
gherkin (2.12.2)
|
gherkin (2.12.2)
|
||||||
multi_json (~> 1.3)
|
multi_json (~> 1.3)
|
||||||
highline (1.6.21)
|
|
||||||
hike (1.2.3)
|
hike (1.2.3)
|
||||||
htmlentities (4.3.1)
|
htmlentities (4.3.1)
|
||||||
i18n (0.6.9)
|
i18n (0.6.9)
|
||||||
|
|
@ -218,7 +217,6 @@ DEPENDENCIES
|
||||||
cucumber-rails
|
cucumber-rails
|
||||||
database_cleaner
|
database_cleaner
|
||||||
factory_girl_rails
|
factory_girl_rails
|
||||||
highline
|
|
||||||
htmlentities
|
htmlentities
|
||||||
jquery-rails
|
jquery-rails
|
||||||
json
|
json
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
namespace :tracks do
|
namespace :tracks do
|
||||||
desc 'Replace the password of USER with a new one.'
|
desc 'Replace the password of USER with a new one.'
|
||||||
task :password => :environment do
|
task :password => :environment do
|
||||||
require "highline/import"
|
require "io/console"
|
||||||
|
|
||||||
user = User.find_by_login(ENV['USER'])
|
user = User.find_by_login(ENV['USER'])
|
||||||
if user.nil?
|
if user.nil?
|
||||||
|
|
@ -10,14 +10,18 @@ namespace :tracks do
|
||||||
end
|
end
|
||||||
|
|
||||||
puts "Changing Tracks password for #{ENV['USER']}."
|
puts "Changing Tracks password for #{ENV['USER']}."
|
||||||
password = ask("New password: ") { |q| q.echo = false }
|
print "New password: "
|
||||||
password_confirmation = ask('Retype new password: ') { |q| q.echo = false }
|
password = STDIN.noecho(&:gets).chomp
|
||||||
|
print "\nRetype new password: "
|
||||||
|
password_confirmation = STDIN.noecho(&:gets).chomp
|
||||||
|
puts
|
||||||
|
|
||||||
begin
|
begin
|
||||||
user.change_password(password, password_confirmation)
|
user.change_password(password, password_confirmation)
|
||||||
|
puts "Password changed."
|
||||||
rescue ActiveRecord::RecordInvalid
|
rescue ActiveRecord::RecordInvalid
|
||||||
puts "Sorry, we couldn't change #{ENV['USER']}'s password: "
|
puts "Sorry, we couldn't change #{ENV['USER']}'s password: "
|
||||||
user.errors.each_full { |msg| puts "- #{msg}\n" }
|
user.errors.full_messages.each { |msg| puts "- #{msg}\n" }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue