includes/clientside/static/login.js
changeset 843 4415e50e4e84
parent 824 28d9fbcd4f0d
child 883 ac2cef868fa9
equal deleted inserted replaced
842:f13bb4f21890 843:4415e50e4e84
   343       
   343       
   344       // Insert the entire message into the login window
   344       // Insert the entire message into the login window
   345       logindata.mb_inner.innerHTML = '';
   345       logindata.mb_inner.innerHTML = '';
   346       logindata.mb_inner.appendChild(div);
   346       logindata.mb_inner.appendChild(div);
   347       
   347       
       
   348       break;
       
   349       
       
   350     default:
       
   351       eval(setHook('login_set_status'));
   348       break;
   352       break;
   349       
   353       
   350     case AJAX_STATUS_DESTROY:
   354     case AJAX_STATUS_DESTROY:
   351     case null:
   355     case null:
   352     case undefined:
   356     case undefined:
   554   }
   558   }
   555   td2_2.appendChild(f_password);
   559   td2_2.appendChild(f_password);
   556   tr2.appendChild(td2_2);
   560   tr2.appendChild(td2_2);
   557   table.appendChild(tr2);
   561   table.appendChild(tr2);
   558   
   562   
       
   563   eval(setHook('login_build_form'));
       
   564   
   559   // Field - captcha
   565   // Field - captcha
   560   if ( show_captcha )
   566   if ( show_captcha )
   561   {
   567   {
   562     var tr3 = document.createElement('tr');
   568     var tr3 = document.createElement('tr');
   563     var td3_1 = document.createElement('td');
   569     var td3_1 = document.createElement('td');
   804       // The user probably clicked ok when the form wasn't in there.
   810       // The user probably clicked ok when the form wasn't in there.
   805       return false;
   811       return false;
   806     }
   812     }
   807   }
   813   }
   808   
   814   
   809   if ( !username )
   815   if ( typeof(username) != 'string' )
   810   {
   816   {
   811     var username = document.getElementById('ajax_login_field_username').value;
   817     var username = document.getElementById('ajax_login_field_username').value;
   812   }
   818   }
   813   if ( !password )
   819   if ( typeof(password) != 'string' )
   814   {
   820   {
   815     var password = document.getElementById('ajax_login_field_password').value;
   821     var password = document.getElementById('ajax_login_field_password').value;
   816   }
   822   }
   817   if ( !captcha && document.getElementById('ajax_login_field_captcha') )
   823   if ( !captcha && document.getElementById('ajax_login_field_captcha') )
   818   {
   824   {
   849   }
   855   }
   850   
   856   
   851   ajaxLoginSetStatus(AJAX_STATUS_LOGGING_IN);
   857   ajaxLoginSetStatus(AJAX_STATUS_LOGGING_IN);
   852   
   858   
   853   // Encrypt the password and username
   859   // Encrypt the password and username
   854   var userinfo = toJSONString({
   860   var userinfo = {
   855       username: username,
   861       username: username,
   856       password: password
   862       password: password
   857     });
   863     };
       
   864     
       
   865   eval(setHook('login_build_userinfo'));
       
   866     
       
   867   userinfo = toJSONString(userinfo);
   858   var crypt_key_ba = hexToByteArray(crypt_key);
   868   var crypt_key_ba = hexToByteArray(crypt_key);
   859   userinfo = stringToByteArray(userinfo);
   869   userinfo = stringToByteArray(userinfo);
   860   
   870   
   861   userinfo = rijndaelEncrypt(userinfo, crypt_key_ba, 'ECB');
   871   userinfo = rijndaelEncrypt(userinfo, crypt_key_ba, 'ECB');
   862   userinfo = byteArrayToHex(userinfo);
   872   userinfo = byteArrayToHex(userinfo);
   955   body.appendChild(errbox);
   965   body.appendChild(errbox);
   956 }
   966 }
   957 
   967 
   958 window.ajaxLoginGetErrorText = function(response)
   968 window.ajaxLoginGetErrorText = function(response)
   959 {
   969 {
       
   970   if ( !response.error_code.match(/^[a-z0-9]+_[a-z0-9_]+$/) )
       
   971   {
       
   972     return response.error_code;
       
   973   }
   960   switch ( response.error_code )
   974   switch ( response.error_code )
   961   {
   975   {
   962     default:
   976     default:
   963       return $lang.get('user_err_' + response.error_code);
   977       var ls = $lang.get('user_err_' + response.error_code);
       
   978       if ( ls == 'user_err_' + response.error_code )
       
   979         ls = $lang.get(response.error_code);
       
   980       
       
   981       return ls;
   964       break;
   982       break;
   965     case 'locked_out':
   983     case 'locked_out':
   966       if ( response.respawn_info.lockout_info.lockout_policy == 'lockout' )
   984       if ( response.respawn_info.lockout_info.lockout_policy == 'lockout' )
   967       {
   985       {
   968         return $lang.get('user_err_locked_out', { 
   986         return $lang.get('user_err_locked_out', { 
  1003       {
  1021       {
  1004         // if we have a lockout policy of captcha or lockout, then warn the user
  1022         // if we have a lockout policy of captcha or lockout, then warn the user
  1005         switch ( response.respawn_info.lockout_info.lockout_policy )
  1023         switch ( response.respawn_info.lockout_info.lockout_policy )
  1006         {
  1024         {
  1007           case 'captcha':
  1025           case 'captcha':
  1008             base += $lang.get('user_err_invalid_credentials_lockout', { 
  1026             base += $lang.get('user_err_invalid_credentials_lockout_captcha', { 
  1009                 fails: response.respawn_info.lockout_info.lockout_fails,
  1027                 fails: response.respawn_info.lockout_info.lockout_fails,
  1010                 lockout_threshold: response.respawn_info.lockout_info.lockout_threshold,
  1028                 lockout_threshold: response.respawn_info.lockout_info.lockout_threshold,
  1011                 lockout_duration: response.respawn_info.lockout_info.lockout_duration
  1029                 lockout_duration: response.respawn_info.lockout_info.lockout_duration
  1012               });
  1030               });
  1013             break;
  1031             break;
  1014           case 'lockout':
  1032           case 'lockout':
       
  1033             base += $lang.get('user_err_invalid_credentials_lockout', { 
       
  1034                 fails: response.respawn_info.lockout_info.lockout_fails,
       
  1035                 lockout_threshold: response.respawn_info.lockout_info.lockout_threshold,
       
  1036                 lockout_duration: response.respawn_info.lockout_info.lockout_duration
       
  1037               });
  1015             break;
  1038             break;
  1016         }
  1039         }
  1017       }
  1040       }
  1018       return base;
  1041       return base;
  1019       break;
  1042       break;