fix(twitter): twitter authentication secret is optional (#16740)
This commit is contained in:
@@ -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', {
|
||||
|
||||
@@ -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')) {
|
||||
|
||||
Reference in New Issue
Block a user