Fixed and improved modules, adding first part support for AWS accounts
This commit is contained in:
@@ -23,17 +23,28 @@ mailListener.on('error', function(err) {
|
||||
function getCodeFromEmail() {
|
||||
return new Promise((resolve) => {
|
||||
mailListener.on('mail', function(mail, seqno, attributes) {
|
||||
if (mail.subject.trim() !== 'Verify your email address') return;
|
||||
if (!attributes) return;
|
||||
const text = mail.text.trim();
|
||||
const match = text.match(/code: (\d+)/i);
|
||||
if (match) {
|
||||
const imap = mailListener.imap;
|
||||
imap.addFlags(attributes.uid, '\\Seen', (err) => {
|
||||
if (err) console.log('Error marking email as seen:', err);
|
||||
// else console.log('Email marked as seen');
|
||||
});
|
||||
resolve(match[1]);
|
||||
if (mail.subject.trim() == 'Verify your email address') {
|
||||
const text = mail.text.trim();
|
||||
const match = text.match(/code: (\d+)/i);
|
||||
if (match) {
|
||||
const imap = mailListener.imap;
|
||||
imap.addFlags(attributes.uid, '\\Seen', (err) => {
|
||||
if (err) console.log('Error marking email as seen:', err);
|
||||
});
|
||||
resolve(match[1]);
|
||||
}
|
||||
}
|
||||
else if (mail.subject.trim() == 'AWS Email Verification') {
|
||||
const text = mail.text.trim();
|
||||
const match = text.match(/code:\s*(\d+)/i);
|
||||
if (match) {
|
||||
const imap = mailListener.imap;
|
||||
imap.addFlags(attributes.uid, '\\Seen', (err) => {
|
||||
if (err) console.log('Error marking email as seen:', err);
|
||||
});
|
||||
resolve(match[1]);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user