fix(twitter): twitter authentication secret is optional (#16740)

This commit is contained in:
zhong666
2024-09-13 21:21:39 +08:00
committed by GitHub
parent ae86fb8c75
commit 8b8dc04eb1
2 changed files with 8 additions and 6 deletions
+1 -1
View File
@@ -154,7 +154,7 @@ async function login({ username, password, authenticationSecret }) {
if (subtask.open_account) {
authentication = subtask.open_account;
break;
} else if (subtask.subtask_id === 'LoginTwoFactorAuthChallenge') {
} else if (authenticationSecret && subtask.subtask_id === 'LoginTwoFactorAuthChallenge') {
const token = authenticator.generate(authenticationSecret);
const task5 = await got.post('https://api.x.com/1.1/onboarding/task.json', {
+7 -5
View File
@@ -21,7 +21,7 @@ const loginLimiter = cache.clients.redisClient
const loginLimiterQueue = new RateLimiterQueue(loginLimiter);
async function login({ username, password, authenticationSecret }) {
if (!username || !password || !authenticationSecret) {
if (!username || !password) {
return;
}
try {
@@ -40,10 +40,12 @@ async function login({ username, password, authenticationSecret }) {
await page.waitForSelector('input[autocomplete="current-password"]');
await page.type('input[autocomplete="current-password"]', password);
(await page.waitForSelector('button[data-testid="LoginForm_Login_Button"]'))?.click();
await page.waitForSelector('input[inputmode="numeric"]');
const token = authenticator.generate(authenticationSecret);
await page.type('input[inputmode="numeric"]', token);
(await page.waitForSelector('button[data-testid="ocfEnterTextNextButton"]'))?.click();
if (authenticationSecret) {
await page.waitForSelector('input[inputmode="numeric"]');
const token = authenticator.generate(authenticationSecret);
await page.type('input[inputmode="numeric"]', token);
(await page.waitForSelector('button[data-testid="ocfEnterTextNextButton"]'))?.click();
}
const waitForRequest = new Promise<string>((resolve) => {
page.on('requestfinished', async (request) => {
if (request.url().includes('/HomeTimeline')) {