diff --git a/src/helpers/logintracker.ts b/src/helpers/logintracker.ts index 4eadcae8..19526d5f 100644 --- a/src/helpers/logintracker.ts +++ b/src/helpers/logintracker.ts @@ -3,7 +3,13 @@ import { sendEmail } from '../utils/sendEmail' export const checkloginAttepmts = async (Profile: any, user: any) => { try { - const { activity } = await Profile.findOne({ user }) + const profile = await Profile.findOne({ user }) + + if(!profile || !profile.activity){ + return; + } + const { activity } = profile + if (activity && activity?.length > 1) { const inline = activity[activity.length - 1] const recent = Number(inline.failed) + 1 || 0 @@ -13,7 +19,7 @@ export const checkloginAttepmts = async (Profile: any, user: any) => { ) { await sendEmail( user.email, - 'SUSPICIOUS ACTIVITY DETECTED ON YOUR ACCOUNT', + 'ALERT!: Unusual Activity Detected on Your Account!', emailtemp(recent, inline.date, inline.country_name, inline.city), '', process.env.COORDINATOR_EMAIL, @@ -41,86 +47,125 @@ export async function checkUserAccountStatus( const emailtemp = (trials: any, date: any, country: any, city: any) => { return ` - -
- -We have detected some suspicious activity on your account. For your security, we recommend taking immediate action to ensure the safety of your account.
-If you believe this activity was unauthorized, please click the button below to reset your password:
- Reset Password -If you recognize this activity and believe it was performed by you, you can safely ignore this message.
-If you have any questions or need further assistance, please contact our support team.
-Best regards,
-Pulse Team
-We have noticed unusual failed login attempts on your account. To secure your account, we recommend resetting your password immediately.
+ + Reset Password + + +| Details | +Information | +
|---|---|
| Date | +${date} | +
| Country | +${country} | +
| City | +${city} | +
| Failed Attempts | +${trials} | +
If this activity was initiated by you, no further action is required.
+Best regards,
+Pulse Team
+ +