mirror of
https://github.com/HeyPuter/puter.git
synced 2026-01-08 22:20:38 -06:00
Send email notifications when 2FA state changes
This commit is contained in:
@@ -83,6 +83,12 @@ module.exports = eggspress('/auth/configure-2fa/:action', {
|
||||
);
|
||||
// update cached user
|
||||
req.user.otp_enabled = 1;
|
||||
|
||||
const svc_email = req.services.get('email');
|
||||
await svc_email.send_email({ email: user.email }, 'enabled_2fa', {
|
||||
username: user.username,
|
||||
});
|
||||
|
||||
return {};
|
||||
};
|
||||
|
||||
@@ -93,6 +99,12 @@ module.exports = eggspress('/auth/configure-2fa/:action', {
|
||||
);
|
||||
// update cached user
|
||||
req.user.otp_enabled = 0;
|
||||
|
||||
const svc_email = req.services.get('email');
|
||||
await svc_email.send_email({ email: user.email }, 'disabled_2fa', {
|
||||
username: user.username,
|
||||
});
|
||||
|
||||
return { success: true };
|
||||
};
|
||||
|
||||
|
||||
@@ -97,6 +97,29 @@ If this was not you, please contact support@puter.com immediately.
|
||||
<p>Puter</p>
|
||||
`,
|
||||
},
|
||||
'enabled_2fa': {
|
||||
subject: '2FA Enabled on your Account',
|
||||
html: `
|
||||
<p>Hi there,</p>
|
||||
<p>We're sending you this email to let you know 2FA was successfully enabled
|
||||
on your account</p>
|
||||
<p>If you did not perform this action please contact support@puter.com
|
||||
immediately</p>
|
||||
<p>Sincerely,</p>
|
||||
<p>Puter</p>
|
||||
`
|
||||
},
|
||||
'disabled_2fa': {
|
||||
subject: '2FA Disabled on your Account',
|
||||
html: `
|
||||
<p>Hi there,</p>
|
||||
<p>We hope you did this on purpose! 2FA Was disabled on your account.</p>
|
||||
<p>If you did not perform this action please contact support@puter.com
|
||||
immediately</p>
|
||||
<p>Sincerely,</p>
|
||||
<p>Puter</p>
|
||||
`
|
||||
}
|
||||
}
|
||||
|
||||
class Emailservice extends BaseService {
|
||||
|
||||
Reference in New Issue
Block a user