From c22efcaee7ba061252e560bc7c6649c2e2c3399d Mon Sep 17 00:00:00 2001 From: Andrew Date: Thu, 26 Oct 2017 23:00:53 -0700 Subject: [PATCH] Feature: add a rake task that's like register but also accepts password and produces cleaner output --- lib/tasks/mastodon.rake | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index de8c0bb86..0ad9d55e2 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -493,6 +493,28 @@ namespace :mastodon do end end + desc 'Machine-readably add a user by providing their email, username and initial password.' \ + 'The user will receive a confirmation email.' + task add_user_automatic: :environment do + print 'Enter email: ' + email = STDIN.gets.chomp + + print 'Enter username: ' + username = STDIN.gets.chomp + + print 'Enter password: ' + password = STDIN.gets.chomp + + user = User.new(email: email, password: password, account_attributes: { username: username }) + if user.save + puts 'User added and confirmation mail sent to user\'s email address.' + else + user.errors.each do |key, val| + STDERR.puts "#{key}: #{val}" + end + end + end + namespace :media do desc 'Removes media attachments that have not been assigned to any status for longer than a day (deprecated)' task clear: :environment do