Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. diff --git lib/tasks/mastodon.rake lib/tasks/mastodon.rake
  2. index 7dd7b5c..416d7eb 100644
  3. --- lib/tasks/mastodon.rake
  4. +++ lib/tasks/mastodon.rake
  5. @@ -10,6 +10,46 @@ namespace :mastodon do
  6. Rake::Task['mastodon:push:refresh'].invoke
  7. end
  8.  
  9. + desc 'Create local user'
  10. + task create_user: :environment do
  11. + print "username: "
  12. + username = STDIN.gets.chomp
  13. +
  14. + print "password: "
  15. + password = STDIN.noecho(&:gets).chomp
  16. + puts
  17. +
  18. + print "password confirmation: "
  19. + password_confirmation = STDIN.noecho(&:gets).chomp
  20. + puts
  21. +
  22. + if password != password_confirmation
  23. + puts "password_confirmation doesn't match password!"
  24. + exit
  25. + end
  26. +
  27. + print "email: "
  28. + email = STDIN.gets.chomp
  29. +
  30. + user = User.new(email: email, password: password, password_confirmation: password_confirmation)
  31. + user.build_account(username: username)
  32. +
  33. + print "Skip confirmation? (y/N)"
  34. + if STDIN.gets.chomp == "y"
  35. + user.skip_confirmation!
  36. + puts "#{email} confirmed"
  37. + end
  38. +
  39. + begin
  40. + user.save!
  41. + puts "#{user.account.username} has created"
  42. + rescue => e
  43. + puts "Something went wrong..."
  44. + puts e.message
  45. + abort
  46. + end
  47. + end
  48. +
  49. desc 'Turn a user into an admin, identified by the USERNAME environment variable'
  50. task make_admin: :environment do
  51. include RoutingHelper
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement