These are chat archives for Ratnesh-Github/NoobWorld

16th
Mar 2015
Ratnesh
@Ratnesh-Github
Mar 16 2015 12:34
``` var x =1
var x = 1;
Ratnesh
@Ratnesh-Github
Mar 16 2015 12:42
Hi guys, I am using request for accessing a website which requires 2 level of authentication. The first level is username and password. Second level is security questions. I am providing the answer directly through server. Though I am getting logged in the website, but the server keeps on trying to login into that site again and again. I can't understand why this is happening.
I am providing the code here :
function start(route){
    http.createServer(function(request,response){

     var pathname = url.parse(request.url).pathname;

    route(pathname);    
    response.writeHead(200,{"Content-Type":"text/html"});
    request1.post({url:'https://system.somesite.loginpage',                
                form: {email:'email@gmail.com', password:'userpassword'},
                followRedirect : true,
                followAllRedirects : true,
                jar : true,
                maxRedirects : 5}, 
                function(err,httpResponse,body){             

                if(!err){                
                body = body.replace(/script/gi, 'script1');

                console.log("Login Successfull Heading for Question and Answers");                

                request1.post({url:'https://otherurl.further',                               
                              form: {email:'email@gmail.com', answer:'something',submitter:'Submit'},
                              followRedirect : true,
                              followAllRedirects : true,
                              jar : true,
                              maxRedirects : 5
                              }, function (err2, httpResponse2, body2) {

                              //GET Request -- Accessing a page after Successful login

                              console.log("QA Successful Heading for getting Account details");
                              request1.get({url:'customerspageurl.com',                                        
                                    followRedirect : true,
                                    followAllRedirects : true,
                                    jar : true,
                                    maxRedirects : 5
                                    },                                            
                                    function (error3, response3, body3) {
                                        console.log("********** Request Complete **************");                                                        response.write(body3);
                                        response.end();    
                                        });
                        });

            }
            else{

                console.log("error ");
            }
    });    

}).listen(8888);
console.log("Server started");
}