Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions lib/mastodon/cli/accounts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,43 @@ def rotate(username = nil)
end
end

desc 'lookup_by_email', 'Lookup account username by email'
long_desc <<-LONG_DESC
Find account username by email for check the email is used in this server.
LONG_DESC
def lookup_by_email(email)
user = User.find_by(email: email)
account = user&.account

if account.present?
say('Found', :green)
say("email : #{email}")
say("username : #{account.username}")
else
say('Not found', :red)
end
end

desc 'lookup_by_username', 'Lookup account email by username'
long_desc <<-LONG_DESC
Find account username by email for login this server.
If you forgot password, use 'accounts modify username --reset-password'.

NOTE: username is NOT indexed in PostgreSQL. This command affects the performance.
LONG_DESC
def lookup_by_username(username)
account = Account.find_by(username: username, domain: nil)
user = account&.user

if user.present?
say('Found', :green)
say("username : #{username}")
say("email : #{user.email}")
else
say('Not found', :red)
end
end

option :email, required: true
option :confirmed, type: :boolean
option :role
Expand Down