includes/clientside/static/login.js
changeset 1026 f0431eb8161e
parent 1002 4d1bb8deee88
child 1052 374d08d176cb
equal deleted inserted replaced
1025:30956e5092ff 1026:f0431eb8161e
    17     return true;
    17     return true;
    18   if ( auth_level >= USER_LEVEL_MEMBER )
    18   if ( auth_level >= USER_LEVEL_MEMBER )
    19     return true;
    19     return true;
    20   ajaxLoginInit(function(k)
    20   ajaxLoginInit(function(k)
    21     {
    21     {
    22       if ( on_main_page )
    22       if ( on_main_page && main_page_members != physical_title )
    23       {
    23       {
    24         window.location = makeUrl(main_page_members);
    24         window.location = makeUrl(main_page_members);
    25       }
    25       }
    26       else
    26       else
    27       {
    27       {
   436     case 'login_failure':
   436     case 'login_failure':
   437       // Rid ourselves of any loading windows
   437       // Rid ourselves of any loading windows
   438       ajaxLoginSetStatus(AJAX_STATUS_DESTROY);
   438       ajaxLoginSetStatus(AJAX_STATUS_DESTROY);
   439       document.getElementById('messageBox').style.backgroundColor = '#C0C0C0';
   439       document.getElementById('messageBox').style.backgroundColor = '#C0C0C0';
   440       var mb_parent = document.getElementById('messageBox').parentNode;
   440       var mb_parent = document.getElementById('messageBox').parentNode;
   441       $(mb_parent).effect("shake", {}, 200);
   441       var do_respawn = ( typeof(response.respawn) == 'boolean' && response.respawn == true ) || typeof(response.respawn) != 'boolean';
   442       setTimeout(function()
   442       if ( do_respawn )
   443         {
   443       {
   444           document.getElementById('messageBox').style.backgroundColor = '#FFF';
   444         $(mb_parent).effect("shake", {}, 200);
   445           ajaxLoginBuildForm(response.respawn_info);
   445         setTimeout(function()
   446           ajaxLoginShowFriendlyError(response);
   446           {
   447         }, 2500);
   447             document.getElementById('messageBox').style.backgroundColor = '#FFF';
       
   448             
       
   449             ajaxLoginBuildForm(response.respawn_info);
       
   450             ajaxLoginShowFriendlyError(response);
       
   451           }, 2500);
       
   452       }
       
   453       else
       
   454       {
       
   455         ajaxLoginShowFriendlyError(response);
       
   456       }
   448       break;
   457       break;
   449     case 'login_success_reset':
   458     case 'login_success_reset':
   450       var conf = confirm($lang.get('user_login_ajax_msg_used_temp_pass'));
   459       var conf = confirm($lang.get('user_login_ajax_msg_used_temp_pass'));
   451       if ( conf )
   460       if ( conf )
   452       {
   461       {
   771   {
   780   {
   772     alert('BUG: AES self-test failed');
   781     alert('BUG: AES self-test failed');
   773     login_cache.mb_object.destroy();
   782     login_cache.mb_object.destroy();
   774     return false;
   783     return false;
   775   }
   784   }
   776   // Early submit hook
       
   777   eval(setHook('login_submit_early'));
       
   778   // Hide the error message and captcha
   785   // Hide the error message and captcha
   779   if ( document.getElementById('ajax_login_error_box') )
   786   if ( document.getElementById('ajax_login_error_box') )
   780   {
   787   {
   781     document.getElementById('ajax_login_error_box').parentNode.removeChild(document.getElementById('ajax_login_error_box'));
   788     document.getElementById('ajax_login_error_box').parentNode.removeChild(document.getElementById('ajax_login_error_box'));
   782   }
   789   }
   841   }
   848   }
   842   if ( !captcha && document.getElementById('ajax_login_field_captcha') )
   849   if ( !captcha && document.getElementById('ajax_login_field_captcha') )
   843   {
   850   {
   844     var captcha = document.getElementById('ajax_login_field_captcha').value;
   851     var captcha = document.getElementById('ajax_login_field_captcha').value;
   845   }
   852   }
       
   853   
       
   854   // Only run early submit hook once
       
   855   if ( !window.logindata.early_submit_run )
       
   856     eval(setHook('login_submit_early'));
       
   857   
       
   858   window.logindata.early_submit_run = true;
   846   
   859   
   847   try
   860   try
   848   {
   861   {
   849   
   862   
   850   if ( do_dh )
   863   if ( do_dh )
   939     ajaxLoginSetStatus(AJAX_STATUS_ERROR);
   952     ajaxLoginSetStatus(AJAX_STATUS_ERROR);
   940     console.error('Exception caught in login process; backtrace follows');
   953     console.error('Exception caught in login process; backtrace follows');
   941     console.debug(e);
   954     console.debug(e);
   942     return false;
   955     return false;
   943   }
   956   }
       
   957   // reset this...
       
   958   window.logindata.early_submit_run = false;
   944   ajaxLoginPerformRequest(json_packet);
   959   ajaxLoginPerformRequest(json_packet);
   945 }
   960 }
   946 
   961 
   947 window.ajaxLoginShowFriendlyError = function(response)
   962 window.ajaxLoginShowFriendlyError = function(response)
   948 {
   963 {