tootctl: add --approve option to tootctl accounts create (#24533)
This commit is contained in:
parent
d02aa274be
commit
b0800d602e
1 changed files with 6 additions and 1 deletions
|
@ -57,6 +57,7 @@ module Mastodon
|
||||||
option :role
|
option :role
|
||||||
option :reattach, type: :boolean
|
option :reattach, type: :boolean
|
||||||
option :force, type: :boolean
|
option :force, type: :boolean
|
||||||
|
option :approve, type: :boolean
|
||||||
desc 'create USERNAME', 'Create a new user account'
|
desc 'create USERNAME', 'Create a new user account'
|
||||||
long_desc <<-LONG_DESC
|
long_desc <<-LONG_DESC
|
||||||
Create a new user account with a given USERNAME and an
|
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
|
account is still in use by someone else, you can supply
|
||||||
the --force option to delete the old record and reattach the
|
the --force option to delete the old record and reattach the
|
||||||
username to the new account anyway.
|
username to the new account anyway.
|
||||||
|
|
||||||
|
With the --approve option, the account will be approved.
|
||||||
LONG_DESC
|
LONG_DESC
|
||||||
def create(username)
|
def create(username)
|
||||||
role_id = nil
|
role_id = nil
|
||||||
|
@ -89,7 +92,7 @@ module Mastodon
|
||||||
|
|
||||||
account = Account.new(username: username)
|
account = Account.new(username: username)
|
||||||
password = SecureRandom.hex
|
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]
|
if options[:reattach]
|
||||||
account = Account.find_local(username) || Account.new(username: username)
|
account = Account.find_local(username) || Account.new(username: username)
|
||||||
|
@ -112,6 +115,8 @@ module Mastodon
|
||||||
user.confirm!
|
user.confirm!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
user.approve! if options[:approve]
|
||||||
|
|
||||||
say('OK', :green)
|
say('OK', :green)
|
||||||
say("New password: #{password}")
|
say("New password: #{password}")
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue