diff options
author | Matt Jankowski <mjankowski@thoughtbot.com> | 2017-05-08 17:08:55 -0400 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-05-08 23:08:55 +0200 |
commit | cd830a2fab3f3c640daeb55e024324b56c079557 (patch) | |
tree | f4e041c0a6f2cfa5c3b3b1b166339fcc78abcb9d /lib | |
parent | aef554d5535fdbb2b34f58bae546ff1b1cac0f22 (diff) |
Improve error message for non-existent user being made an admin (#2929)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tasks/mastodon.rake | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/tasks/mastodon.rake b/lib/tasks/mastodon.rake index 290b28098..b71c578a6 100644 --- a/lib/tasks/mastodon.rake +++ b/lib/tasks/mastodon.rake @@ -18,11 +18,15 @@ namespace :mastodon do desc 'Turn a user into an admin, identified by the USERNAME environment variable' task make_admin: :environment do include RoutingHelper + account_username = ENV.fetch('USERNAME') + user = User.joins(:account).where(accounts: { username: account_username }) - user = Account.find_local(ENV.fetch('USERNAME')).user - user.update(admin: true) - - puts "Congrats! #{user.account.username} is now an admin. \\o/\nNavigate to #{edit_admin_settings_url} to get started" + if user.present? + user.update(admin: true) + puts "Congrats! #{account_username} is now an admin. \\o/\nNavigate to #{edit_admin_settings_url} to get started" + else + puts "User could not be found; please make sure an Account with the `#{account_username}` username exists." + end end desc 'Manually confirms a user with associated user email address stored in USER_EMAIL environment variable.' |