My application supports normal registration for admin roles and registration by invite for team members. Admins can successfully register themselves. Login functionality is also working fine. I am using jwt for token generation and AuthGuards
to protect private routes.
Need some help on how I can send an invitation url to users? (nodemailer already configured and working). More concerned about url generation.
Can someone help me? The application backend is in nestjs and frontend is in angular 8. Currently I am testing apis through postman.
Thanks in advance, Ajinkya
1) Create a database entity invitation-token
with one column token
(randomly generated UUID, e.g. with this uuid lib). Set it to self-delete entries after 24 hours. (e.g. TTL in mongodb)
2) Create an endpoint that allows registration with a query param invitation-token
,
e.g. /registration?invitation-token=Usa67Nsus78
. It only allows registration if the given token exists in the table created in step 1).
3) Create an invite
endpoint that takes a mail address as input. It creates a new token in the invitation-token
table and sends an email to the given address with a link to the endpoint in 2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With