Hi everybody! Is there any way to have a trigger o...
# help
h
Hi everybody! Is there any way to have a trigger or any kind of action/middleware in the authentication service?, like for example; what if I want to restrict the sign-up only for e-mails from a specific domain @example.com? I tried searching but can't really find anything related. Thank you so much in advance.
n
Hello @Haus Of Alejandro! This thread has been automatically created from your message in #843999948717555735 a few seconds ago. We have already mentioned the @User so that they can see your message and help you as soon as possible! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ``...`` menu) and select "Leave Thread" to unsubscribe from future updates. Want to change the title? Use the ``/title`` command! We have solved your problem? Click the button below to archive it.
g
Yes you can trigger on the auth.users table before insert and return null if user's email is not what you want.
h
Thanks @garyaustin May I ask, if I return null that avoids the user creation in the database iteself, but does also prevent sending the e-mail for sign-up? I want to use magic links
g
I think so, but I was not using magic links when I tested a long time ago. You could research more or just try it.
h
@garyaustin for sure! thank you so much, will bring back the result just in case it is useful for someone else.
oh... it prevents the new user to be inserted on the table, but it still sends the e-mail link.
g
bummer
If this is only for those who should not use your app, you could just write the template to say only company emails will work with this link or some such.
You can also do a "friendly" check on the client side so you don't even send it. Then you are only dealing with people who bypass your client check so blocking them even in a non elegant way should be ok..
h
Yes, I think the second workaround wouldn't be so bad, basically what I want is to "deny" the authentication for users that do not belong to a specific domain. And as long they are not part of the users table...
what if I use a custom STMP server?, that's something quite new for me... so I don't know if I can do some logic there, or it is just a provider that I connect and the mails are going to be sent from there anyway
g
If you found a STMP service that allowed logic on their side, that might work, but I've never researched that.
h
I need to experiment first of course haha, but now I have the context, thank you so much!
n
Thread was archived by @Haus Of Alejandro. Anyone can send a message to unarchive it.