- Fix login not working
- Sessions are now saved after logging in
- Check if promotions, and searches are available before counting total point amount
This commit is contained in:
TheNetsky
2024-03-01 12:19:48 +01:00
parent cf7f7ac790
commit 64048e35d7
5 changed files with 26 additions and 20 deletions

View File

@@ -2,6 +2,7 @@ import { Page } from 'playwright'
import readline from 'readline'
import { MicrosoftRewardsBot } from '../index'
import { saveSessionData } from '../util/Load'
const rl = readline.createInterface({
input: process.stdin,
@@ -26,14 +27,12 @@ export class Login {
if (!isLoggedIn) {
// Check if account is locked
const isLocked = await page.waitForSelector('.serviceAbusePageContainer', { state: 'visible', timeout: 10_000 }).then(() => true).catch(() => false)
const isLocked = await page.waitForSelector('.serviceAbusePageContainer', { state: 'visible', timeout: 1000 }).then(() => true).catch(() => false)
if (isLocked) {
this.bot.log('LOGIN', 'This account has been locked!', 'error')
throw new Error('Account has been locked!')
}
await page.waitForSelector('#loginHeader', { state: 'visible', timeout: 10_000 })
await this.execLogin(page, email, password)
this.bot.log('LOGIN', 'Logged into Microsoft successfully')
} else {
@@ -43,6 +42,9 @@ export class Login {
// Check if logged in to bing
await this.checkBingLogin(page)
// Save session
await saveSessionData(this.bot.config.sessionPath, page.context(), email, this.bot.isMobile)
// We're done logging in
this.bot.log('LOGIN', 'Logged in successfully')