@@ -3,7 +3,13 @@ import { sendEmail } from '../utils/sendEmail'
33
44export const checkloginAttepmts = async ( Profile : any , user : any ) => {
55 try {
6- const { activity } = await Profile . findOne ( { user } )
6+ const profile = await Profile . findOne ( { user } )
7+
8+ if ( ! profile || ! profile . activity ) {
9+ return ;
10+ }
11+ const { activity } = profile
12+
713 if ( activity && activity ?. length > 1 ) {
814 const inline = activity [ activity . length - 1 ]
915 const recent = Number ( inline . failed ) + 1 || 0
@@ -13,7 +19,7 @@ export const checkloginAttepmts = async (Profile: any, user: any) => {
1319 ) {
1420 await sendEmail (
1521 user . email ,
16- 'SUSPICIOUS ACTIVITY DETECTED ON YOUR ACCOUNT ' ,
22+ 'ALERT!: Unusual Activity Detected on Your Account! ' ,
1723 emailtemp ( recent , inline . date , inline . country_name , inline . city ) ,
1824 '' ,
1925 process . env . COORDINATOR_EMAIL ,
@@ -41,86 +47,125 @@ export async function checkUserAccountStatus(
4147
4248const emailtemp = ( trials : any , date : any , country : any , city : any ) => {
4349 return `<!DOCTYPE html>
44- <html>
45- <head>
46- <meta charset="UTF-8">
47- <title>Suspicious Activity Detected</title>
48- <style>
49- body {
50- background-color: #f5f5f5;
51- font-family: Arial, sans-serif;
52- margin: 0;
53- padding: 0;
54- }
55-
56- .container {
57- max-width: 600px;
58- margin: 20px auto;
59- background-color: #ffffff;
60- padding: 20px;
61- border-radius: 4px;
62- box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
63- }
64-
65- h1 {
66- color: #333333;
67- font-size: 24px;
68- margin: 0;
69- }
70-
71- p {
72- color: #666666;
73- font-size: 16px;
74- line-height: 1.6;
75- margin: 10px 0;
76- }
77-
78- .cta-button {
50+ <html>
51+ <head>
52+ <meta charset="UTF-8">
53+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
54+ <title>Suspicious Activity Detected</title>
55+ <style>
56+ body {
57+ background-color: #f9f9f9;
58+ font-family: 'Arial', sans-serif;
59+ margin: 0;
60+ padding: 0;
61+ }
62+
63+ .container {
64+ max-width: 600px;
65+ margin: 30px auto;
66+ background-color: #ffffff;
67+ padding: 20px 30px;
68+ border-radius: 8px;
69+ box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
70+ }
71+
72+ h1 {
73+ color: #2c3e50;
74+ font-size: 22px;
75+ margin-bottom: 10px;
76+ }
77+
78+ p {
79+ color: #7f8c8d;
80+ font-size: 15px;
81+ line-height: 1.6;
82+ }
83+
84+ .details-table {
85+ width: 100%;
86+ border-collapse: collapse;
87+ margin-top: 15px;
88+ }
89+
90+ .details-table th,
91+ .details-table td {
92+ text-align: left;
93+ padding: 10px;
94+ border-bottom: 1px solid #ecf0f1;
95+ }
96+
97+ .details-table th {
98+ background-color: #f4f6f7;
99+ color: #34495e;
100+ font-weight: bold;
101+ }
102+
103+ .cta-button {
79104 display: inline-block;
80105 margin-top: 20px;
81- background-color: #4caf50;
82- color: #ffffff ;
106+ background-color: #6a1b9a; /* Deep purple */
107+ color: white ;
83108 font-size: 16px;
84109 text-decoration: none;
85- padding: 10px 20px;
86- border-radius: 4px;
87- }
88-
110+ padding: 12px 25px;
111+ border-radius: 6px;
112+ transition: background-color 0.3s ease;
113+ }
114+
89115 .cta-button:hover {
90- background-color: #45a049;
91- }
92- #det{
93- display:grid;
94- padding: 10% 5%;
95- border: 2px solid red;
96-
97- }
98- li{
99- margin:2% 0%;
116+ background-color: #4a148c; /* Darker shade of purple for hover effect */
100117 }
101- </style>
102- </head>
103- <body>
104- <div class="container">
105- <h1>Suspicious Activity Detected</h1>
106- <p>We have detected some suspicious activity on your account. For your security, we recommend taking immediate action to ensure the safety of your account.</p>
107- <p>If you believe this activity was unauthorized, please click the button below to reset your password:</p>
108- <a class="cta-button" href="${ process . env . FRONTEND_LINK } /reset-password">Reset Password</a>
109- <div id="det">
110-
111- <li>date:${ date } </li>
112- <li>country name: ${ country } </li>
113- <li>city: ${ city } </li>
114- <li>failed attempts:${ trials } </li>
115- </div>
116-
117-
118- <p>If you recognize this activity and believe it was performed by you, you can safely ignore this message.</p>
119- <p>If you have any questions or need further assistance, please contact our support team.</p>
120- <p>Best regards,</p>
121- <p>Pulse Team</p>
122- </div>
123- </body>
124- </html>
125- `
118+
119+
120+ .footer {
121+ margin-top: 20px;
122+ font-size: 12px;
123+ color: #bdc3c7;
124+ text-align: center;
125+ }
126+ </style>
127+ </head>
128+ <body>
129+ <div class="container">
130+ <p>We have noticed unusual failed login attempts on your account. To secure your account, we recommend resetting your password immediately.</p>
131+ <a class="cta-button"
132+ style="color: white !important; background-color: #6a1b9a; padding: 12px 25px;
133+ font-size: 16px; border-radius: 6px; text-decoration: none;"
134+ href="${ process . env . FRONTEND_LINK } /reset-password">
135+ Reset Password
136+ </a>
137+
138+ <table class="details-table">
139+ <thead>
140+ <tr>
141+ <th>Details</th>
142+ <th>Information</th>
143+ </tr>
144+ </thead>
145+ <tbody>
146+ <tr>
147+ <td>Date</td>
148+ <td>${ date } </td>
149+ </tr>
150+ <tr>
151+ <td>Country</td>
152+ <td>${ country } </td>
153+ </tr>
154+ <tr>
155+ <td>City</td>
156+ <td>${ city } </td>
157+ </tr>
158+ <tr>
159+ <td>Failed Attempts</td>
160+ <td>${ trials } </td>
161+ </tr>
162+ </tbody>
163+ </table>
164+ <p>If this activity was initiated by you, no further action is required.</p>
165+ <p>Best regards,</p>
166+ <p>Pulse Team</p>
167+ <div class="footer">Your security is our priority. Contact support if you need assistance.</div>
168+ </div>
169+ </body>
170+ </html>` ;
126171}
0 commit comments