AMP-SCZ / subject-id-gen

Subject ID Generator
Apache License 2.0
0 stars 0 forks source link

[ENH] Send an email to users after granting access #12

Open tashrifbillah opened 3 years ago

tashrifbillah commented 3 years ago

Otherwise user won't know ...

tashrifbillah commented 3 years ago

The email notification should be inserted before this line (see note below): https://github.com/AMP-SCZ/subject-id-gen/blob/4316038a15ac5696c299cdcf26358544f86c0087/src/pages/admin/add-site.jsx#L42

Here is one notification currently in action: https://github.com/AMP-SCZ/subject-id-gen/blob/4316038a15ac5696c299cdcf26358544f86c0087/src/pages/api/auth/register.js#L69

that makes use of the template: https://github.com/AMP-SCZ/subject-id-gen/blob/4316038a15ac5696c299cdcf26358544f86c0087/src/lib/mail.js#L31

The same template can be used as a trial template for setting up the stated notification as:

       await sendVerificationEmail({
         email: 'my@email.com',
         token: 'HELLO',
       });

That means, insert the above block before the aforementioned line.


User's info can be found as:

https://github.com/AMP-SCZ/subject-id-gen/blob/4316038a15ac5696c299cdcf26358544f86c0087/src/pages/api/auth/verify-email.js#L34-L42

After finding user's info, the above block can be made exact:

       await sendVerificationEmail({
         email: email,
         token: token: e.currentTarget.siteId.value.toUpperCase(),
       });

Finally, write an email template e.g. notifiySiteApprovalEmail echoing sendVerificationEmail template.


Note I am not sure what code exactly 'sends' the email. This should also be looked at:

https://github.com/AMP-SCZ/subject-id-gen/blob/main/src/pages/verify-email/%5Btoken%5D.jsx#L21-L34