Is your feature request related to a problem? Please describe.
Currently, we are sending out authentication mails, containing only OTP nothing else, making sub-standard offerings.
We need to integrate these templates so that mail goes with data in a formatted manner.
Describe the solution you'd like
[x] In the src/utils/dataFormat.ts file, create a new function hbsToHtml() which
takes input as .hbs template filename and the variable data to be replaced in the template.
variable data can be taken in as an object and provided to handlebars later.
we will be overlooking integration of the logo for the scope of this issue, we will be doing that later.
returns the compiled HTML using handlebars.
following can be used as a reference
const rawHTML=await promises.readFile(__dirname+"/../../assets/"+fileName,{encoding:"utf-8"});
let template=Handlebars.compile(rawHTML)
return template(replacements);
[x] Now move to src/utils/communication.ts, where we will be integrating the templates actually
reach out to sendOtp function, we need to add an argument for name of user as well here.
we will provide this name to mailOtp & messageOtp function, updating their function definition as well.
in mailOtp function we can see a function sendMail() been called, with 3 arguments, third one been the actual HTML been sent.
in here we will replace the <div>${otpHash}<div>, with the HTML as output from the hbsToHtml function.
in the functions, sendOtp, mailOtp, messageOtp, we can see otpHash is the argument instead of otp, as we are sending otp and not its hash, so kindly update it as well.
[x] Updating function definition for sendOtp will cause need of changes in the following file as well
src/controllers/user/resendOtp - do provide necessary inputs like name, otp and template file name
src/controllers/user/registerUser - do provide necessary inputs like name, otp and template file name
integration of template of forgot password will take place at a later point, first the controller will need an update alltogether.
Additional context
All detailed updates to be done already mentioned...
Is your feature request related to a problem? Please describe.
Describe the solution you'd like
<div>${otpHash}<div>
, with the HTML as output from the hbsToHtml function.Additional context
All detailed updates to be done already mentioned...