If I'm writing a nextjs API route and want to chec...
# javascript
c
If I'm writing a nextjs API route and want to check if some email addresses are already registered, and if not, send an email, which methods are most suitable? I see there's a listUsers method on auth.api, which looks promising maybe? If I use generateLink or inviteUserByEmail, do I (can I?) receive their (new) user ID immediately?
g
On inviteUserByEmail, I think you get back an error if email exists, and a user object, without confirmation being set if it sends the email. This is based on glancing at code as docs don't say much. I've not tried it though. That might work to both check and send email. You could also use an rpc function to check auth.users for email, but you probably want some protection in it so it can't be called by anyone.