Improve error message for non-existent user being made an admin (#2929)
This commit is contained in:
		
							parent
							
								
									062e8f04d3
								
							
						
					
					
						commit
						d8632a9ced
					
				
					 1 changed files with 8 additions and 4 deletions
				
			
		|  | @ -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 | ||||
|     if user.present? | ||||
|       user.update(admin: true) | ||||
| 
 | ||||
|     puts "Congrats! #{user.account.username} is now an admin. \\o/\nNavigate to #{edit_admin_settings_url} to get started" | ||||
|       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.' | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue