httpauth/login-hook.js
changeset 0 29e93991703b
equal deleted inserted replaced
-1:000000000000 0:29e93991703b
       
     1 addOnloadHook(function()
       
     2 	{
       
     3 		attachHook('login_build_form', 'http_auth_login_hook(table, data);');
       
     4 	});
       
     5 
       
     6 function http_auth_login_hook(table, data)
       
     7 {
       
     8 	if ( window.shift )
       
     9 		return;
       
    10 	
       
    11 	if (window.logindata.user_level <= USER_LEVEL_MEMBER)
       
    12 	{
       
    13 		window.location = makeUrlNS('Special', 'LoginHTTP');
       
    14 	}
       
    15 	else
       
    16 	{
       
    17 		// re-auth
       
    18 		ajaxGet(makeUrlNS('Special', 'LoginHTTP', 'ajax&level=' + window.logindata.user_level), function(xhr)
       
    19 			{
       
    20 				if ( xhr.readyState == 4 && xhr.status == 200 ) {
       
    21 					var result = JSON.parse(xhr.responseText);
       
    22 					if ( result.result == 'success' ) {
       
    23 						window.logindata.successfunc(result.sid);
       
    24 					}
       
    25 				}
       
    26 			});
       
    27 	}
       
    28 }