feat: Enhance login state detection with strict checks for portal elements and improved handling of unknown states

This commit is contained in:
2025-11-04 23:09:31 +01:00
parent d89816c817
commit 4e8bd59ff4
2 changed files with 35 additions and 10 deletions

View File

@@ -461,13 +461,24 @@ export class Login {
)
if (passwordPageReached === LoginState.LoggedIn) {
this.bot.log(this.bot.isMobile, 'LOGIN', 'Already authenticated after email (fast path)')
return
// Double-check: verify we're actually on rewards portal with activities
const actuallyLoggedIn = await page.locator('#more-activities, html[data-role-name*="RewardsPortal"]')
.first()
.isVisible({ timeout: 2000 })
.catch(() => false)
if (actuallyLoggedIn) {
this.bot.log(this.bot.isMobile, 'LOGIN', 'Already authenticated after email (fast path)')
return
} else {
this.bot.log(this.bot.isMobile, 'LOGIN', 'False positive on LoggedIn state, continuing with password entry', 'warn')
// Continue to password entry
}
}
if (!passwordPageReached) {
this.bot.log(this.bot.isMobile, 'LOGIN', 'Password page not reached after 8s, continuing anyway...', 'warn')
} else {
} else if (passwordPageReached !== LoginState.LoggedIn) {
this.bot.log(this.bot.isMobile, 'LOGIN', `Transitioned to state: ${passwordPageReached}`)
}