about summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2023-04-22 19:13:02 +0200
committerGitHub <noreply@github.com>2023-04-22 19:13:02 +0200
commit2ebbfebfe9c7c967e3bcc9da0eec4628f9188233 (patch)
treeed3fa3f23d520e99fdd8b19597992b59a47aaa7d /lib
parentf30c5e7f15f967019245d2c78f3c2e89800eb838 (diff)
parent9ef32ea570fd0db63bd75714cd847abad6833345 (diff)
Merge pull request #2192 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'lib')
-rw-r--r--lib/mastodon/accounts_cli.rb10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/mastodon/accounts_cli.rb b/lib/mastodon/accounts_cli.rb
index a6532541e..5194cd80a 100644
--- a/lib/mastodon/accounts_cli.rb
+++ b/lib/mastodon/accounts_cli.rb
@@ -57,6 +57,7 @@ module Mastodon
     option :role
     option :reattach, type: :boolean
     option :force, type: :boolean
+    option :approve, type: :boolean
     desc 'create USERNAME', 'Create a new user account'
     long_desc <<-LONG_DESC
       Create a new user account with a given USERNAME and an
@@ -72,6 +73,8 @@ module Mastodon
       account is still in use by someone else, you can supply
       the --force option to delete the old record and reattach the
       username to the new account anyway.
+
+      With the --approve option, the account will be approved.
     LONG_DESC
     def create(username)
       role_id  = nil
@@ -89,7 +92,7 @@ module Mastodon
 
       account  = Account.new(username: username)
       password = SecureRandom.hex
-      user     = User.new(email: options[:email], password: password, agreement: true, approved: true, role_id: role_id, confirmed_at: options[:confirmed] ? Time.now.utc : nil, bypass_invite_request_check: true)
+      user     = User.new(email: options[:email], password: password, agreement: true, role_id: role_id, confirmed_at: options[:confirmed] ? Time.now.utc : nil, bypass_invite_request_check: true)
 
       if options[:reattach]
         account = Account.find_local(username) || Account.new(username: username)
@@ -112,6 +115,8 @@ module Mastodon
           user.confirm!
         end
 
+        user.approve! if options[:approve]
+
         say('OK', :green)
         say("New password: #{password}")
       else
@@ -184,9 +189,10 @@ module Mastodon
       user.disabled = true if options[:disable]
       user.approved = true if options[:approve]
       user.otp_required_for_login = false if options[:disable_2fa]
-      user.confirm if options[:confirm]
 
       if user.save
+        user.confirm if options[:confirm]
+
         say('OK', :green)
         say("New password: #{password}") if options[:reset_password]
       else