···1010 let%lwt () =
1111 Util.send_email_or_log ~recipients:[To email]
1212 ~subject:"Confirm PLC operation"
1313- ~body:
1414- (Plain
1515- (Printf.sprintf
1616- "Confirm that you would like to update your PLC identity for \
1717- %s (%s) using the following token: %s"
1818- handle did code ) )
1313+ ~body:(Emails.PlcOperation.make ~handle ~did ~code)
1914 in
2015 Dream.empty `OK )
+1-4
pegasus/lib/api/server/requestAccountDelete.ml
···1111 let%lwt () = Data_store.set_auth_code ~did ~code ~expires_at db in
1212 Util.send_email_or_log ~recipients:[To actor.email]
1313 ~subject:(Printf.sprintf "Account deletion request for %s" actor.handle)
1414- ~body:
1515- (Plain
1616- (Printf.sprintf "Delete your account using the following token: %s"
1717- code ) )
1414+ ~body:(Emails.AccountDelete.make ~handle:actor.handle ~code)
18151916let calc_key_did ctx = Some (Auth.get_authed_did_exn ctx.Xrpc.auth)
2017
···1313 let%lwt () =
1414 Util.send_email_or_log ~recipients:[To actor.email]
1515 ~subject:(Printf.sprintf "Confirm email for %s" actor.handle)
1616- ~body:
1717- (Plain
1818- (Printf.sprintf
1919- "Confirm your email address using the following token: %s"
2020- code ) )
1616+ ~body:(Emails.EmailConfirmation.make ~handle:actor.handle ~code)
2117 in
2218 Lwt.return_ok ()
2319
+1-7
pegasus/lib/api/server/requestEmailUpdate.ml
···2828 in
2929 Util.send_email_or_log ~recipients:[To to_email]
3030 ~subject:(Printf.sprintf "Confirm email change for %s" actor.handle)
3131- ~body:
3232- (Plain
3333- (Printf.sprintf
3434- "Confirm that you would like to change your email address%s \
3535- using the following token: %s"
3636- (match pending_email with Some e -> " to " ^ e | None -> "")
3737- code ) )
3131+ ~body:(Emails.EmailUpdate.make ~handle:actor.handle ~new_email:pending_email ~code)
3832 else Lwt.return_unit
3933 in
4034 Lwt.return token_required
+1-4
pegasus/lib/api/server/requestPasswordReset.ml
···1313 let%lwt () = Data_store.set_auth_code ~did ~code ~expires_at db in
1414 Util.send_email_or_log ~recipients:[To actor.email]
1515 ~subject:(Printf.sprintf "Password reset for %s" actor.handle)
1616- ~body:
1717- (Plain
1818- (Printf.sprintf "Reset your password using the following token: %s"
1919- code ) )
1616+ ~body:(Emails.PasswordReset.make ~handle:actor.handle ~code)
20172118let handler =
2219 Xrpc.handler
···11+open EmailStyles
22+33+let html_body ~handle ~new_email ~code : JSX.element =
44+ let destination_text =
55+ match new_email with
66+ | Some email ->
77+ <span style=Styles.link>(JSX.string (" to " ^ email))</span>
88+ | None ->
99+ JSX.string ""
1010+ in
1111+ <div>
1212+ <p style=Styles.paragraph>
1313+ (JSX.string "Hello, ")
1414+ <span style=Styles.link>(JSX.string handle)</span>
1515+ (JSX.string "!")
1616+ </p>
1717+ <p style=Styles.paragraph>
1818+ (JSX.string
1919+ "Please confirm that you would like to change your email address" )
2020+ destination_text
2121+ (JSX.string " using the token below:")
2222+ </p>
2323+ <div style=Styles.code_block>(JSX.string code)</div>
2424+ <p style=Styles.small_text>
2525+ (JSX.string "This token will expire in 10 minutes.")
2626+ </p>
2727+ <p style=Styles.small_text>
2828+ (JSX.string
2929+ "If you didn't request this email change, you can ignore this email." )
3030+ </p>
3131+ </div>
3232+3333+let plain_text ~handle ~new_email ~code : string =
3434+ let destination_text =
3535+ match new_email with Some email -> " to " ^ email | None -> ""
3636+ in
3737+ Printf.sprintf
3838+ "Hello, %s!\n\n\
3939+ Please confirm that you would like to change your email address%s using \
4040+ the token below:\n\n\
4141+ %s\n\n\
4242+ This token will expire in 10 minutes.\n\n\
4343+ If you didn't request this email change, you can ignore this email."
4444+ handle destination_text code
4545+4646+let make ~handle ~new_email ~code : Letters.body =
4747+ let html_content = html_body ~handle ~new_email ~code in
4848+ let template_content =
4949+ EmailTemplate.
5050+ { title= "Confirm email change for " ^ handle
5151+ ; heading= "confirm email change"
5252+ ; body= html_content
5353+ ; footer= Some ("This is an automated message from " ^ Env.hostname ^ ".")
5454+ }
5555+ in
5656+ let html = EmailTemplate.make ~content:template_content () |> JSX.render in
5757+ let plain = plain_text ~handle ~new_email ~code in
5858+ Mixed (plain, html, None)
+47
pegasus/lib/emails/passwordReset.mlx
···11+open EmailStyles
22+33+let html_body ~handle ~code : JSX.element =
44+ <div>
55+ <p style=Styles.paragraph>
66+ (JSX.string "Hello, ")
77+ <span style=Styles.link>(JSX.string handle)</span>
88+ (JSX.string "!")
99+ </p>
1010+ <p style=Styles.paragraph>
1111+ (JSX.string
1212+ "You requested a password reset for your account. Use the token below \
1313+ to reset your password:" )
1414+ </p>
1515+ <div style=Styles.code_block>(JSX.string code)</div>
1616+ <p style=Styles.small_text>
1717+ (JSX.string "This token will expire in 10 minutes.")
1818+ </p>
1919+ <p style=Styles.small_text>
2020+ (JSX.string
2121+ "If you didn't request this password reset, you can ignore this email." )
2222+ </p>
2323+ </div>
2424+2525+let plain_text ~handle ~code : string =
2626+ Printf.sprintf
2727+ "Hello, %s!\n\n\
2828+ You requested a password reset for your account. Use the token below to \
2929+ reset your password:\n\n\
3030+ %s\n\n\
3131+ This token will expire in 10 minutes.\n\n\
3232+ If you didn't request this password reset, you can ignore this email."
3333+ handle code
3434+3535+let make ~handle ~code : Letters.body =
3636+ let html_content = html_body ~handle ~code in
3737+ let template_content =
3838+ EmailTemplate.
3939+ { title= "Password reset for " ^ handle
4040+ ; heading= "password reset"
4141+ ; body= html_content
4242+ ; footer= Some ("This is an automated message from " ^ Env.hostname ^ ".")
4343+ }
4444+ in
4545+ let html = EmailTemplate.make ~content:template_content () |> JSX.render in
4646+ let plain = plain_text ~handle ~code in
4747+ Mixed (plain, html, None)
+45
pegasus/lib/emails/plcOperation.mlx
···11+open EmailStyles
22+33+let html_body ~handle ~did ~code : JSX.element =
44+ <div>
55+ <p style=Styles.paragraph>
66+ (JSX.string
77+ "Use the following code to confirm that you would like to update your \
88+ identity for:" )
99+ </p>
1010+ <p style=Styles.link>(JSX.string (handle ^ " (" ^ did ^ ")"))</p>
1111+ <div style=Styles.code_block>(JSX.string code)</div>
1212+ <p style=Styles.small_text>
1313+ (JSX.string "This token will expire in 1 hour.")
1414+ </p>
1515+ <p style=Styles.small_text>
1616+ (JSX.string
1717+ "If you didn't request this operation, you can safely ignore this \
1818+ email." )
1919+ </p>
2020+ </div>
2121+2222+let plain_text ~handle ~did ~code : string =
2323+ Printf.sprintf
2424+ "Use the following code to confirm that you would like to update your \
2525+ identity for:\n\n\
2626+ %s (%s)\n\n\
2727+ %s\n\n\
2828+ This token will expire in 1 hour.\n\n\
2929+ If you didn't request this operation, you can safely ignore this email."
3030+ handle did code
3131+3232+(* Generate complete email body *)
3333+let make ~handle ~did ~code : Letters.body =
3434+ let html_content = html_body ~handle ~did ~code in
3535+ let template_content =
3636+ EmailTemplate.
3737+ { title= "Confirm PLC operation"
3838+ ; heading= "confirm plc operation"
3939+ ; body= html_content
4040+ ; footer= Some ("This is an automated message from " ^ Env.hostname ^ ".")
4141+ }
4242+ in
4343+ let html = EmailTemplate.make ~content:template_content () |> JSX.render in
4444+ let plain = plain_text ~handle ~did ~code in
4545+ Mixed (plain, html, None)