Browse Source

Re-added add_user_automatic rake task (#3)

LenPayne 4 weeks ago
parent
commit
d510ef7375
1 changed files with 22 additions and 0 deletions
  1. 22
    0
      lib/tasks/mastodon.rake

+ 22
- 0
lib/tasks/mastodon.rake View File

@@ -388,6 +388,28 @@ namespace :mastodon do
388 388
     end
389 389
   end
390 390
 
391
+  desc 'Machine-readably add a user by providing their email, username and initial password.' \
392
+      'The user will receive a confirmation email.'
393
+  task add_user_automatic: :environment do
394
+    print 'Enter email: '
395
+    email = STDIN.gets.chomp
396
+
397
+    print 'Enter username: '
398
+    username = STDIN.gets.chomp
399
+
400
+    print 'Enter password: '
401
+    password = STDIN.gets.chomp
402
+
403
+    user = User.new(email: email, password: password, account_attributes: { username: username })
404
+    if user.save
405
+      puts 'User added and confirmation mail sent to user\'s email address.'
406
+    else
407
+      user.errors.each do |key, val|
408
+        STDERR.puts "#{key}: #{val}"
409
+      end
410
+    end
411
+  end
412
+
391 413
   namespace :webpush do
392 414
     desc 'Generate VAPID key'
393 415
     task generate_vapid_key: :environment do