mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-11 17:56:15 +00:00
Update to recovery email management: makes the recoveryEmail field optional and adds the ability to disable recovery email verification per account. Added corresponding documentation and updated configuration examples.
This commit is contained in:
@@ -294,12 +294,37 @@ export function loadAccounts(): Account[] {
|
||||
}
|
||||
a.email = String(a.email).trim()
|
||||
a.password = String(a.password)
|
||||
if (typeof a.recoveryEmail !== 'string') {
|
||||
throw new Error(`account ${a.email || '<unknown>'} must include a recoveryEmail string`)
|
||||
const recoveryRequired = a.recoveryRequired !== false
|
||||
a.recoveryRequired = recoveryRequired
|
||||
|
||||
if (recoveryRequired) {
|
||||
if (typeof a.recoveryEmail !== 'string') {
|
||||
throw new Error(`account ${a.email || '<unknown>'} must include a recoveryEmail string`)
|
||||
}
|
||||
a.recoveryEmail = String(a.recoveryEmail).trim()
|
||||
if (!a.recoveryEmail || !/@/.test(a.recoveryEmail)) {
|
||||
throw new Error(`account ${a.email} recoveryEmail must be a valid email address`)
|
||||
}
|
||||
} else {
|
||||
if (typeof a.recoveryEmail === 'string' && a.recoveryEmail.trim() !== '') {
|
||||
const trimmed = a.recoveryEmail.trim()
|
||||
if (!/@/.test(trimmed)) {
|
||||
throw new Error(`account ${a.email} recoveryEmail must be a valid email address`)
|
||||
}
|
||||
a.recoveryEmail = trimmed
|
||||
} else {
|
||||
a.recoveryEmail = undefined
|
||||
}
|
||||
}
|
||||
a.recoveryEmail = String(a.recoveryEmail).trim()
|
||||
if (!a.recoveryEmail || !/@/.test(a.recoveryEmail)) {
|
||||
throw new Error(`account ${a.email} recoveryEmail must be a valid email address`)
|
||||
|
||||
if (!a.proxy || typeof a.proxy !== 'object') {
|
||||
a.proxy = { proxyAxios: true, url: '', port: 0, username: '', password: '' }
|
||||
} else {
|
||||
a.proxy.proxyAxios = a.proxy.proxyAxios !== false
|
||||
a.proxy.url = typeof a.proxy.url === 'string' ? a.proxy.url : ''
|
||||
a.proxy.port = typeof a.proxy.port === 'number' ? a.proxy.port : 0
|
||||
a.proxy.username = typeof a.proxy.username === 'string' ? a.proxy.username : ''
|
||||
a.proxy.password = typeof a.proxy.password === 'string' ? a.proxy.password : ''
|
||||
}
|
||||
}
|
||||
// Filter out disabled accounts (enabled: false)
|
||||
|
||||
@@ -91,26 +91,43 @@ export class StartupValidator {
|
||||
)
|
||||
}
|
||||
|
||||
// Required: recoveryEmail (NEW - mandatory field)
|
||||
if (!account.recoveryEmail || typeof account.recoveryEmail !== 'string') {
|
||||
this.addError(
|
||||
'accounts',
|
||||
`${prefix}: Missing required field "recoveryEmail"`,
|
||||
'Add your recovery/backup email address. This is MANDATORY for security checks.\nExample: "recoveryEmail": "backup@gmail.com"',
|
||||
'docs/accounts.md'
|
||||
)
|
||||
} else if (!/@/.test(account.recoveryEmail)) {
|
||||
this.addError(
|
||||
'accounts',
|
||||
`${prefix}: Recovery email format is invalid`,
|
||||
'Recovery email must be a valid email address (e.g., backup@gmail.com)'
|
||||
)
|
||||
} else if (account.recoveryEmail.trim() === '') {
|
||||
this.addError(
|
||||
'accounts',
|
||||
`${prefix}: Recovery email cannot be empty`,
|
||||
'Provide the actual recovery email associated with this Microsoft account'
|
||||
)
|
||||
const recoveryRequired = account.recoveryRequired !== false
|
||||
if (recoveryRequired) {
|
||||
if (!account.recoveryEmail || typeof account.recoveryEmail !== 'string') {
|
||||
this.addError(
|
||||
'accounts',
|
||||
`${prefix}: Missing required field "recoveryEmail"`,
|
||||
'Add your recovery/backup email address. This is required for security checks unless you explicitly disable it.\nExample: "recoveryEmail": "backup@gmail.com"',
|
||||
'docs/accounts.md'
|
||||
)
|
||||
} else if (!/@/.test(account.recoveryEmail)) {
|
||||
this.addError(
|
||||
'accounts',
|
||||
`${prefix}: Recovery email format is invalid`,
|
||||
'Recovery email must be a valid email address (e.g., backup@gmail.com)'
|
||||
)
|
||||
} else if (account.recoveryEmail.trim() === '') {
|
||||
this.addError(
|
||||
'accounts',
|
||||
`${prefix}: Recovery email cannot be empty`,
|
||||
'Provide the actual recovery email associated with this Microsoft account'
|
||||
)
|
||||
}
|
||||
} else {
|
||||
if (!account.recoveryEmail || account.recoveryEmail.trim() === '') {
|
||||
this.addWarning(
|
||||
'accounts',
|
||||
`${prefix}: Recovery email checks disabled`,
|
||||
'The bot will skip recovery-email mismatch detection for this account. Re-enable by removing "recoveryRequired": false.',
|
||||
'docs/accounts.md'
|
||||
)
|
||||
} else if (!/@/.test(account.recoveryEmail)) {
|
||||
this.addError(
|
||||
'accounts',
|
||||
`${prefix}: Recovery email format is invalid`,
|
||||
'Recovery email must be a valid email address (e.g., backup@gmail.com)'
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Optional but recommended: TOTP
|
||||
|
||||
Reference in New Issue
Block a user