DEV: Introduce users:exists rake task (#27163)

Checks if a user exists for given email address
This commit is contained in:
Brendan Bell 2024-06-13 08:04:02 +01:00 committed by GitHub
parent ae1d8c50da
commit 0a2926ae03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 0 deletions

View File

@ -210,6 +210,17 @@ task "users:list_recent_staff" => :environment do
puts "user_ids = [#{all_ids.uniq.join(",")}]"
end
desc "Check if a user exists for given email address"
task "users:exists", [:email] => [:environment] do |_, args|
email = args[:email]
if User.find_by_email(email)
puts "User with email #{email} exists"
exit 0
end
puts "ERROR: User with email #{email} not found"
exit 1
end
def find_user(username)
user = User.find_by_username(username)