-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
code refactoring, welcome email added, profile section, otp verificat…
…ion in profile section
- Loading branch information
1 parent
b8507ed
commit 0181d0c
Showing
21 changed files
with
647 additions
and
653 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
const getOtpMailBody = (otp:number) => { | ||
return ` | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>OTP Verification</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f4f4f4; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
.container { | ||
width: 100%; | ||
max-width: 600px; | ||
margin: 0 auto; | ||
background-color: #ffffff; | ||
padding: 20px; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | ||
border-radius: 8px; | ||
} | ||
.header { | ||
background-color: #4CAF50; | ||
color: white; | ||
padding: 10px 0; | ||
text-align: center; | ||
border-radius: 8px 8px 0 0; | ||
} | ||
.content { | ||
margin: 20px 0; | ||
text-align: center; | ||
} | ||
.otp { | ||
font-size: 24px; | ||
font-weight: bold; | ||
margin: 20px 0; | ||
color: #4CAF50; | ||
} | ||
.footer { | ||
text-align: center; | ||
color: #888888; | ||
font-size: 12px; | ||
margin-top: 20px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<div class="header"> | ||
<h1>OTP Verification</h1> | ||
</div> | ||
<div class="content"> | ||
<p>Hello,</p> | ||
<p>Thank you for using style share. Please use the following OTP (One Time Password) to verify your email address:</p> | ||
<div class="otp">${otp}</div> | ||
<p>This OTP is valid for 10 minutes. Please do not share it with anyone.</p> | ||
</div> | ||
<div class="footer"> | ||
<p>If you did not request this OTP, please ignore this email.</p> | ||
<p>Thank you!</p> | ||
</div> | ||
</div> | ||
</body> | ||
</html> | ||
` | ||
} | ||
|
||
export default getOtpMailBody; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import nodemailer from "nodemailer"; | ||
import getOtpMailBody from "./otpMailBody"; | ||
|
||
export const sendVerificationEmail = async (email: string, otp: number) => { | ||
let transporter = nodemailer.createTransport({ | ||
service: "Gmail", | ||
auth: { | ||
user: process.env.EMAIL_USER, | ||
pass: process.env.EMAIL_PASS, | ||
}, | ||
}); | ||
|
||
let info = await transporter.sendMail({ | ||
from: '"Style Share" <[email protected]>', | ||
to: email, | ||
subject: "Email Verification", | ||
text: `Your OTP for email verification is ${otp}`, | ||
html: getOtpMailBody(otp), | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import nodemailer from "nodemailer"; | ||
|
||
export const sendWelcomeEmail = async (email: string, username: string) => { | ||
let transporter = nodemailer.createTransport({ | ||
service: "Gmail", | ||
auth: { | ||
user: process.env.EMAIL_USER, | ||
pass: process.env.EMAIL_PASS, | ||
}, | ||
}); | ||
|
||
let info = await transporter.sendMail({ | ||
from: '"Style Share" <[email protected]>', | ||
to: email, | ||
subject: "Welcome to Style Share!", | ||
text: `Welcome to Style Share, ${username}!`, | ||
html: getWelcomeMailBody(username), | ||
}); | ||
}; | ||
|
||
const getWelcomeMailBody = (username: string) => { | ||
return ` | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Welcome to Style Share</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
background-color: #f4f4f4; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
.container { | ||
width: 100%; | ||
max-width: 600px; | ||
margin: 0 auto; | ||
background-color: #ffffff; | ||
padding: 20px; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | ||
border-radius: 8px; | ||
} | ||
.header { | ||
background-color: #4CAF50; | ||
color: white; | ||
padding: 10px 0; | ||
text-align: center; | ||
border-radius: 8px 8px 0 0; | ||
} | ||
.content { | ||
margin: 20px 0; | ||
text-align: center; | ||
} | ||
.footer { | ||
text-align: center; | ||
color: #888888; | ||
font-size: 12px; | ||
margin-top: 20px; | ||
} | ||
.reset-link { | ||
color: #4CAF50; | ||
text-decoration: none; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<div class="header"> | ||
<h1>Welcome to Style Share!</h1> | ||
</div> | ||
<div class="content"> | ||
<p>Hello ${username},</p> | ||
<p>Thank you for signing up for Style Share. We are excited to have you on board!</p> | ||
<p>If this account does not belong to you, please <a class="reset-link" href="https://yourapp.example.com/reset-password">reset your password</a> immediately from our website.</p> | ||
</div> | ||
<div class="footer"> | ||
<p>If you created this account, please verify this email in profile section.</p> | ||
<p>Thank you!</p> | ||
</div> | ||
</div> | ||
</body> | ||
</html> | ||
`; | ||
}; | ||
|
||
export default getWelcomeMailBody; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.