Results 1 to 6 of 6
  1. mgmft's Avatar
    Posts
    199 Posts
    Global Posts
    230 Global Posts
       #1  
    Hi,

    until now I didn`t use the login procedure for my app (VDRemote). After some users requested, that login should be implemented, I am currently working on this. I only use an existing web frontend. I have a small method "request" to trigger all commands and for now it worked, except the logging in. My method looks like this:

    Code:
    	request: function(url) {
    		var myAjax = new Ajax.Request(url, {
    			method: "get",
    			evalJSON: 'force',
    			contentType: 'application/x-www-form-urlencoded',
    			requestHeaders: {
    				"USER_AGENT": navigator.userAgent
    			},
    		});
    	},
    To log in I use the above method called with the url:
    Code:
    		var url = "http://" + WBPrefs.vdrip + ":" + WBPrefs.vdrport + "/?action=login&login=" + WBPrefs.vdruser + "&password=" + WBPrefs.vdrpassword; 
    		this.request(url);

    I call the method in the main views "setup:" part. It works, but it takes 30 (!) seconds until I can use the app as normal. What could be the problem?


    Using HttpFox and logging in from the web leads to the following information:

    (Request-Line) GET /?action=login&login=user&password=password HTTP/1.1
    Host 192.168.2.31:6001
    User-Agent Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 (.NET CLR 3.5.30729)
    Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
    Accept-Encoding gzip,deflate
    Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive 115
    Connection keep-alive
    Referer http://192.168.2.31:6001/
    Cookie tntnet.=ca483c3cf2600a7baed40f514a788202
    (Status-Line) HTTP/1.1 302 moved temporarily
    Connection Keep-Alive
    Content-Length 94
    Content-Type text/html; charset=iso-8859-15
    Date Mon, 10 May 2010 18:43:08 GMT
    Keep-Alive timeout=15000, max=970
    Location whats_on.html?type=now
    Server Tntnet/1.6.2
    Thanks for any help!

    Marcel
  2. #2  
    Im not entirely familiar with VDR or its plugins, but from my experience very rarely are users authenticated to webapps via GET. I betting you need to POST that data. Just an educated guess.

    Hope that helps..
    --bitshifter1001
  3. #3  
    A 30 second timeout sounds suspiciously like a DNS timeout, in case that helps. Bitshifter1001's comment about POST vs GET is on the money too.

    Cheers, Steve
  4. mgmft's Avatar
    Posts
    199 Posts
    Global Posts
    230 Global Posts
       #4  
    Hi,

    I tired "post" or "put":

    Code:
    	requestpost: function(url) {
    		var myAjax = new Ajax.Request(url, {
    			method: 'put',
    			evalJSON: 'force',
    			contentType: 'application/x-www-form-urlencoded',
    			requestHeaders: {
    				"USER_AGENT": navigator.userAgent
    			},
    With the same result! Any other suggestion?

    Thanks

    Marcel
  5. #5  
    Hi mgmft,

    Lets look at a few things.

    1) Is the url correct? Manually go to the login page and double check.
    Does that url = "http://" + WBPrefs.vdrip + ":" + WBPrefs.vdrport"?

    2) You probably need to send the username / pwd in the POST body. (Note: the paramater names I used are generic and will need to match the form names on your login page. View HTML source to find those field names.)

    Code:
    request: function(url, username, pwd) {
        var params = 'username=' + username + '&password='+pwd;
        var myAjax = new Ajax.Request(url, {
            method: "POST",
            contentType: 'application/x-www-form-urlencoded',
            parameters: params,
            onFailure: handleError,
            onComplete: handleSuccess        
        });
    },
    
    function handleError(response) {
        Mojo.Log.error("Status: " + response.status + " Text: " + response.responseText );
        //Do other interesting things
    }
    
    function handleSuccess(response) {
        Mojo.Log.info("Status: " + response.status + " Text: " + response.responseText );
    }
    Code:
    var url = "http://" + WBPrefs.vdrip + ":" + WBPrefs.vdrport;
    this.request(url, WBPrefs.vdruser, WBPrefs.vdrpassword);

    Hope this is a little more clear.
    --bitshifter1001
  6. mgmft's Avatar
    Posts
    199 Posts
    Global Posts
    230 Global Posts
       #6  
    Hi bitshifter,

    THANKS!!!!! You are great. I had to change the code a bit, but now ot works

    Code:
    	requestpost: function(url, username, pwd) {
    	  var params = '/?action=login&login=' + username + '&password='+pwd;
        var myAjax = new Ajax.Request(url, {
            method: "POST",
            contentType: 'application/x-www-form-urlencoded',
            parameters: params,
            onFailure: handleError,
            onComplete: handleSuccess        
        });
    THANKS A LOT!!!!

Posting Permissions