includes/clientside/static/login.js
author Dan
Mon, 16 Feb 2009 13:01:35 -0500
changeset 829 87fcc7175c61
parent 824 28d9fbcd4f0d
child 843 4415e50e4e84
permissions -rw-r--r--
Fixed https urls not allowed in user_extra CPs; fixed nonworking password reset in admin CP
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
     1
/*
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
     2
 * AJAX-based intelligent login interface
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
     3
 */
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
     4
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
     5
/*
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
     6
 * FRONTEND
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
     7
 */
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
     8
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
     9
/**
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    10
 * Performs a logon as a regular member.
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    11
 */
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    12
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
    13
window.ajaxLogonToMember = function()
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    14
{
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    15
  // IE <6 pseudo-compatibility
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    16
  if ( KILL_SWITCH )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    17
    return true;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    18
  if ( auth_level >= USER_LEVEL_MEMBER )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    19
    return true;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    20
  ajaxLoginInit(function(k)
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    21
    {
741
a216e412c439 Added ability to have alternate main page for members
Dan
parents: 728
diff changeset
    22
      if ( on_main_page )
a216e412c439 Added ability to have alternate main page for members
Dan
parents: 728
diff changeset
    23
      {
a216e412c439 Added ability to have alternate main page for members
Dan
parents: 728
diff changeset
    24
        window.location = makeUrl(main_page_members);
a216e412c439 Added ability to have alternate main page for members
Dan
parents: 728
diff changeset
    25
      }
a216e412c439 Added ability to have alternate main page for members
Dan
parents: 728
diff changeset
    26
      else
a216e412c439 Added ability to have alternate main page for members
Dan
parents: 728
diff changeset
    27
      {
a216e412c439 Added ability to have alternate main page for members
Dan
parents: 728
diff changeset
    28
        window.location.reload();
a216e412c439 Added ability to have alternate main page for members
Dan
parents: 728
diff changeset
    29
      }
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    30
    }, USER_LEVEL_MEMBER);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    31
}
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    32
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    33
/**
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    34
 * Authenticates to the highest level the current user is allowed to go to.
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    35
 */
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    36
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
    37
window.ajaxLogonToElev = function()
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    38
{
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    39
  if ( auth_level == user_level )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    40
    return true;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    41
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    42
  ajaxLoginInit(function(k)
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    43
    {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    44
      ENANO_SID = k;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    45
      var url = String(' ' + window.location).substr(1);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    46
      url = append_sid(url);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    47
      window.location = url;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    48
    }, user_level);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    49
}
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    50
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    51
/*
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    52
 * BACKEND
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    53
 */
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    54
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    55
/**
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    56
 * Holding object for various AJAX authentication information.
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    57
 * @var object
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    58
 */
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    59
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    60
var logindata = {};
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    61
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    62
/**
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    63
 * Path to the image used to indicate loading progress
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    64
 * @var string
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    65
 */
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    66
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    67
if ( !ajax_login_loadimg_path )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    68
  var ajax_login_loadimg_path = false;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    69
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    70
if ( !ajax_login_successimg_path )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    71
  var ajax_login_successimg_path = false;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    72
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    73
/**
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    74
 * Status variables
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    75
 * @var int
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    76
 */
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    77
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    78
var AJAX_STATUS_LOADING_KEY = 1;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    79
var AJAX_STATUS_GENERATING_KEY = 2;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    80
var AJAX_STATUS_LOGGING_IN = 3;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    81
var AJAX_STATUS_SUCCESS = 4;
718
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
    82
var AJAX_STATUS_ERROR = 5;
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    83
var AJAX_STATUS_DESTROY = 65535;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    84
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    85
/**
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    86
 * State constants
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    87
 * @var int
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    88
 */
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    89
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    90
var AJAX_STATE_EARLY_INIT = 1;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    91
var AJAX_STATE_LOADING_KEY = 2;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    92
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    93
/**
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    94
 * Performs the AJAX request to get an encryption key and from there spawns the login form.
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    95
 * @param function The function that will be called once authentication completes successfully.
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    96
 * @param int The security level to authenticate at - see http://docs.enanocms.org/Help:Appendix_B
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    97
 */
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
    98
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
    99
window.ajaxLoginInit = function(call_on_finish, user_level)
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   100
{
780
f65e35566b63 A few fixes to the most recently added feature: more efficiency tweaks, tweaked l10n to have beetter fetch-on-demand support to ensure that stubs are never returned
Dan
parents: 779
diff changeset
   101
  load_component(['messagebox', 'flyin', 'fadefilter', 'jquery', 'jquery-ui', 'l10n', 'crypto']);
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   102
  
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   103
  logindata = {};
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   104
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   105
  var title = ( user_level > USER_LEVEL_MEMBER ) ? $lang.get('user_login_ajax_prompt_title_elev') : $lang.get('user_login_ajax_prompt_title');
550
685e839d934e Added ability to delete the draft revision; [SECURITY] fixed lack of permission check on draft save; renamed messagebox() constructor to MessageBox() (backward compat. maintained)
Dan
parents: 532
diff changeset
   106
  logindata.mb_object = new MessageBox(MB_OKCANCEL | MB_ICONLOCK, title, '');
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   107
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   108
  logindata.mb_object.onclick['Cancel'] = function()
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   109
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   110
    // Hide the error message and captcha
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   111
    if ( document.getElementById('ajax_login_error_box') )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   112
    {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   113
      document.getElementById('ajax_login_error_box').parentNode.removeChild(document.getElementById('ajax_login_error_box'));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   114
    }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   115
    if ( document.getElementById('autoCaptcha') )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   116
    {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   117
      var to = fly_out_top(document.getElementById('autoCaptcha'), false, true);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   118
      setTimeout(function() {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   119
          var d = document.getElementById('autoCaptcha');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   120
          d.parentNode.removeChild(d);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   121
        }, to);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   122
    }
471
7906fb190fc1 Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents: 461
diff changeset
   123
    // Ask the server to clean our key
7906fb190fc1 Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents: 461
diff changeset
   124
    ajaxLoginPerformRequest({
7906fb190fc1 Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents: 461
diff changeset
   125
        mode: 'clean_key',
7906fb190fc1 Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents: 461
diff changeset
   126
        key_aes: logindata.key_aes,
7906fb190fc1 Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents: 461
diff changeset
   127
        key_dh: logindata.key_dh
7906fb190fc1 Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents: 461
diff changeset
   128
    });
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   129
  };
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   130
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   131
  logindata.mb_object.onbeforeclick['OK'] = function()
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   132
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   133
    ajaxLoginSubmitForm();
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   134
    return true;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   135
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   136
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   137
  // Fetch the inner content area
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   138
  logindata.mb_inner = document.getElementById('messageBox').getElementsByTagName('div')[0];
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   139
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   140
  // Initialize state
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   141
  logindata.showing_status = false;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   142
  logindata.user_level = user_level;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   143
  logindata.successfunc = call_on_finish;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   144
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   145
  // Build the "loading" window
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   146
  ajaxLoginSetStatus(AJAX_STATUS_LOADING_KEY);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   147
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   148
  // Request the key
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   149
  ajaxLoginPerformRequest({ mode: 'getkey' });
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   150
}
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   151
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   152
/**
532
03429d7b1537 Finally fixed link coloring settings in Oxygen Bleu; added compatibility wrapper for people that "ajaxLogonInit" over "ajaxLoginInit"
Dan
parents: 509
diff changeset
   153
 * For compatibility only.
03429d7b1537 Finally fixed link coloring settings in Oxygen Bleu; added compatibility wrapper for people that "ajaxLogonInit" over "ajaxLoginInit"
Dan
parents: 509
diff changeset
   154
 */
03429d7b1537 Finally fixed link coloring settings in Oxygen Bleu; added compatibility wrapper for people that "ajaxLogonInit" over "ajaxLoginInit"
Dan
parents: 509
diff changeset
   155
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   156
window.ajaxLogonInit = function(call_on_finish, user_level)
532
03429d7b1537 Finally fixed link coloring settings in Oxygen Bleu; added compatibility wrapper for people that "ajaxLogonInit" over "ajaxLoginInit"
Dan
parents: 509
diff changeset
   157
{
03429d7b1537 Finally fixed link coloring settings in Oxygen Bleu; added compatibility wrapper for people that "ajaxLogonInit" over "ajaxLoginInit"
Dan
parents: 509
diff changeset
   158
  return ajaxLoginInit(call_on_finish, user_level);
03429d7b1537 Finally fixed link coloring settings in Oxygen Bleu; added compatibility wrapper for people that "ajaxLogonInit" over "ajaxLoginInit"
Dan
parents: 509
diff changeset
   159
}
03429d7b1537 Finally fixed link coloring settings in Oxygen Bleu; added compatibility wrapper for people that "ajaxLogonInit" over "ajaxLoginInit"
Dan
parents: 509
diff changeset
   160
03429d7b1537 Finally fixed link coloring settings in Oxygen Bleu; added compatibility wrapper for people that "ajaxLogonInit" over "ajaxLoginInit"
Dan
parents: 509
diff changeset
   161
/**
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   162
 * Sets the contents of the AJAX login window to the appropriate status message.
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   163
 * @param int One of AJAX_STATUS_*
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   164
 */
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   165
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   166
window.ajaxLoginSetStatus = function(status)
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   167
{
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   168
  if ( !logindata.mb_inner )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   169
    return false;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   170
  if ( logindata.showing_status )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   171
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   172
    var div = document.getElementById('ajax_login_status');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   173
    if ( div )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   174
      logindata.mb_inner.removeChild(div);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   175
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   176
  switch(status)
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   177
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   178
    case AJAX_STATUS_LOADING_KEY:
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   179
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   180
      // Create the status div
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   181
      var div = document.createElement('div');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   182
      div.id = 'ajax_login_status';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   183
      div.style.marginTop = '10px';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   184
      div.style.textAlign = 'center';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   185
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   186
      // The circly ball ajaxy image + status message
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   187
      var status_msg = $lang.get('user_login_ajax_fetching_key');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   188
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   189
      // Insert the status message
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   190
      div.appendChild(document.createTextNode(status_msg));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   191
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   192
      // Append a br or two to space things properly
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   193
      div.appendChild(document.createElement('br'));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   194
      div.appendChild(document.createElement('br'));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   195
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   196
      var img = document.createElement('img');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   197
      img.src = ( ajax_login_loadimg_path ) ? ajax_login_loadimg_path : scriptPath + '/images/loading-big.gif';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   198
      div.appendChild(img);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   199
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   200
      // Another coupla brs
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   201
      div.appendChild(document.createElement('br'));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   202
      div.appendChild(document.createElement('br'));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   203
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   204
      // The link to the full login form
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   205
      var small = document.createElement('small');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   206
      small.innerHTML = $lang.get('user_login_ajax_link_fullform', { link_full_form: makeUrlNS('Special', 'Login/' + title) });
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   207
      div.appendChild(small);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   208
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   209
      // Insert the entire message into the login window
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   210
      logindata.mb_inner.innerHTML = '';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   211
      logindata.mb_inner.appendChild(div);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   212
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   213
      break;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   214
    case AJAX_STATUS_GENERATING_KEY:
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   215
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   216
      // Create the status div
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   217
      var div = document.createElement('div');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   218
      div.id = 'ajax_login_status';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   219
      div.style.marginTop = '10px';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   220
      div.style.textAlign = 'center';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   221
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   222
      // The circly ball ajaxy image + status message
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   223
      var status_msg = $lang.get('user_login_ajax_generating_key');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   224
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   225
      // Insert the status message
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   226
      div.appendChild(document.createTextNode(status_msg));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   227
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   228
      // Append a br or two to space things properly
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   229
      div.appendChild(document.createElement('br'));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   230
      div.appendChild(document.createElement('br'));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   231
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   232
      var img = document.createElement('img');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   233
      img.src = ( ajax_login_loadimg_path ) ? ajax_login_loadimg_path : scriptPath + '/images/loading-big.gif';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   234
      div.appendChild(img);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   235
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   236
      // Another coupla brs
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   237
      div.appendChild(document.createElement('br'));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   238
      div.appendChild(document.createElement('br'));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   239
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   240
      // The link to the full login form
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   241
      var small = document.createElement('small');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   242
      small.innerHTML = $lang.get('user_login_ajax_link_fullform_dh', { link_full_form: makeUrlNS('Special', 'Login/' + title) });
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   243
      div.appendChild(small);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   244
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   245
      // Insert the entire message into the login window
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   246
      logindata.mb_inner.innerHTML = '';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   247
      logindata.mb_inner.appendChild(div);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   248
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   249
      break;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   250
    case AJAX_STATUS_LOGGING_IN:
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   251
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   252
      // Create the status div
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   253
      var div = document.createElement('div');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   254
      div.id = 'ajax_login_status';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   255
      div.style.marginTop = '10px';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   256
      div.style.textAlign = 'center';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   257
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   258
      // The circly ball ajaxy image + status message
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   259
      var status_msg = $lang.get('user_login_ajax_loggingin');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   260
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   261
      // Insert the status message
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   262
      div.appendChild(document.createTextNode(status_msg));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   263
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   264
      // Append a br or two to space things properly
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   265
      div.appendChild(document.createElement('br'));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   266
      div.appendChild(document.createElement('br'));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   267
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   268
      var img = document.createElement('img');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   269
      img.src = ( ajax_login_loadimg_path ) ? ajax_login_loadimg_path : scriptPath + '/images/loading-big.gif';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   270
      div.appendChild(img);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   271
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   272
      // Insert the entire message into the login window
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   273
      logindata.mb_inner.innerHTML = '';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   274
      logindata.mb_inner.appendChild(div);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   275
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   276
      break;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   277
    case AJAX_STATUS_SUCCESS:
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   278
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   279
      // Create the status div
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   280
      var div = document.createElement('div');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   281
      div.id = 'ajax_login_status';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   282
      div.style.marginTop = '10px';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   283
      div.style.textAlign = 'center';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   284
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   285
      // The circly ball ajaxy image + status message
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   286
      var status_msg = $lang.get('user_login_success_short');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   287
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   288
      // Insert the status message
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   289
      div.appendChild(document.createTextNode(status_msg));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   290
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   291
      // Append a br or two to space things properly
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   292
      div.appendChild(document.createElement('br'));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   293
      div.appendChild(document.createElement('br'));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   294
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   295
      var img = document.createElement('img');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   296
      img.src = ( ajax_login_successimg_path ) ? ajax_login_successimg_path : scriptPath + '/images/check.png';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   297
      div.appendChild(img);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   298
      
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   299
      // Insert the entire message into the login window
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   300
      logindata.mb_inner.innerHTML = '';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   301
      logindata.mb_inner.appendChild(div);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   302
      
718
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   303
      break;
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   304
      
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   305
    case AJAX_STATUS_ERROR:
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   306
      // Create the status div
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   307
      var div = document.createElement('div');
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   308
      div.id = 'ajax_login_status';
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   309
      div.style.marginTop = '10px';
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   310
      div.style.textAlign = 'center';
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   311
      
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   312
      // The circly ball ajaxy image + status message
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   313
      var status_msg = $lang.get('user_login_ajax_err_crypto');
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   314
      
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   315
      // Insert the status message
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   316
      div.appendChild(document.createTextNode(status_msg));
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   317
      
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   318
      // Append a br or two to space things properly
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   319
      div.appendChild(document.createElement('br'));
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   320
      div.appendChild(document.createElement('br'));
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   321
      
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   322
      var img = document.createElement('img');
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   323
      img.src = ( ajax_login_successimg_path ) ? ajax_login_successimg_path : scriptPath + '/images/checkbad.png';
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   324
      div.appendChild(img);
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   325
      
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   326
      // Append a br or two to space things properly
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   327
      div.appendChild(document.createElement('br'));
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   328
      div.appendChild(document.createElement('br'));
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   329
      
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   330
      // The circly ball ajaxy image + status message
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   331
      var detail_msg = $lang.get('user_login_ajax_err_crypto_details');
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   332
      var full_link = $lang.get('user_login_ajax_err_crypto_link');
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   333
      var link = document.createElement('a');
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   334
      link.href = makeUrlNS('Special', 'Login/' + title);
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   335
      link.appendChild(document.createTextNode(full_link));
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   336
      var span = document.createElement('span');
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   337
      span.style.fontSize = 'smaller';
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   338
      
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   339
      // Insert the message
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   340
      span.appendChild(document.createTextNode(detail_msg + ' '));
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   341
      span.appendChild(link);
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   342
      div.appendChild(span);
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   343
      
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   344
      // Insert the entire message into the login window
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   345
      logindata.mb_inner.innerHTML = '';
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   346
      logindata.mb_inner.appendChild(div);
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   347
      
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   348
      break;
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   349
      
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   350
    case AJAX_STATUS_DESTROY:
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   351
    case null:
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   352
    case undefined:
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   353
      logindata.showing_status = false;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   354
      return null;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   355
      break;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   356
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   357
  logindata.showing_status = true;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   358
}
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   359
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   360
/**
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   361
 * Performs an AJAX logon request to the server and calls ajaxLoginProcessResponse() on the result.
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   362
 * @param object JSON packet to send
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   363
 */
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   364
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   365
window.ajaxLoginPerformRequest = function(json)
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   366
{
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   367
  json = toJSONString(json);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   368
  json = ajaxEscape(json);
824
28d9fbcd4f0d Login: reauth: window.location.hash is now updated to include the new SID so that page reloads will use it
Dan
parents: 816
diff changeset
   369
  ajaxPost(makeUrlNS('Special', 'Login/action.json'), 'r=' + json, function(ajax)
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   370
    {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   371
      if ( ajax.readyState == 4 && ajax.status == 200 )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   372
      {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   373
        // parse response
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   374
        var response = String(ajax.responseText + '');
651
ce9d78d7251d Improved JSON validation and error interface when validation fails; made rank manager support custom CSS
Dan
parents: 585
diff changeset
   375
        if ( !check_json_response(response) )
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   376
        {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   377
          handle_invalid_json(response);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   378
          return false;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   379
        }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   380
        response = parseJSON(response);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   381
        ajaxLoginProcessResponse(response);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   382
      }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   383
    }, true);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   384
}
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   385
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   386
/**
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   387
 * Processes a response from the login server
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   388
 * @param object JSON response
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   389
 */
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   390
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   391
window.ajaxLoginProcessResponse = function(response)
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   392
{
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   393
  // Did the server send a plaintext error?
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   394
  if ( response.mode == 'error' )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   395
  {
811
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
   396
    if ( logindata.mb_object )
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
   397
    {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
   398
      logindata.mb_object.destroy();
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
   399
      var error_msg = $lang.get('user_' + ( response.error.toLowerCase() ));
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
   400
      new MessageBox(MB_ICONSTOP | MB_OK, $lang.get('user_err_login_generic_title'), error_msg);
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
   401
    }
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
   402
    else
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
   403
    {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
   404
      alert(response.error);
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
   405
    }
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   406
    return false;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   407
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   408
  // Main mode switch
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   409
  switch ( response.mode )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   410
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   411
    case 'build_box':
471
7906fb190fc1 Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents: 461
diff changeset
   412
      // Rid ourselves of any loading windows
7906fb190fc1 Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents: 461
diff changeset
   413
      ajaxLoginSetStatus(AJAX_STATUS_DESTROY);
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   414
      // The server wants us to build the login form, all the information is there
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   415
      ajaxLoginBuildForm(response);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   416
      break;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   417
    case 'login_success':
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   418
      ajaxLoginSetStatus(AJAX_STATUS_SUCCESS);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   419
      logindata.successfunc(response.key);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   420
      break;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   421
    case 'login_failure':
471
7906fb190fc1 Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents: 461
diff changeset
   422
      // Rid ourselves of any loading windows
7906fb190fc1 Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents: 461
diff changeset
   423
      ajaxLoginSetStatus(AJAX_STATUS_DESTROY);
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   424
      document.getElementById('messageBox').style.backgroundColor = '#C0C0C0';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   425
      var mb_parent = document.getElementById('messageBox').parentNode;
728
067a6173820c [minor] Login box shook too slowly on failure
Dan
parents: 718
diff changeset
   426
      $(mb_parent).effect("shake", {}, 200);
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   427
      setTimeout(function()
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   428
        {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   429
          document.getElementById('messageBox').style.backgroundColor = '#FFF';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   430
          ajaxLoginBuildForm(response.respawn_info);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   431
          ajaxLoginShowFriendlyError(response);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   432
        }, 2500);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   433
      break;
472
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   434
    case 'login_success_reset':
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   435
      var conf = confirm($lang.get('user_login_ajax_msg_used_temp_pass'));
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   436
      if ( conf )
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   437
      {
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   438
        var url = makeUrlNS('Special', 'PasswordReset/stage2/' + response.user_id + '/' + response.temp_password);
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   439
        window.location = url;
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   440
      }
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   441
      else
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   442
      {
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   443
        // treat as a failure
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   444
        ajaxLoginSetStatus(AJAX_STATUS_DESTROY);
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   445
        document.getElementById('messageBox').style.backgroundColor = '#C0C0C0';
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   446
        var mb_parent = document.getElementById('messageBox').parentNode;
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 694
diff changeset
   447
        $(mb_parent).effect("shake", {}, 1500);
472
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   448
        setTimeout(function()
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   449
          {
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   450
            document.getElementById('messageBox').style.backgroundColor = '#FFF';
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   451
            ajaxLoginBuildForm(response.respawn_info);
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   452
            // don't show an error here, just silently respawn
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   453
          }, 2500);
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   454
      }
bc4b58034f4d Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents: 471
diff changeset
   455
      break;
811
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
   456
    case 'logout_success':
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
   457
      if ( ENANO_SID )
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
   458
      {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
   459
        ajaxLoginReplaceSIDInline(false, ENANO_SID, USER_LEVEL_MEMBER);
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
   460
      }
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
   461
      break;
471
7906fb190fc1 Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents: 461
diff changeset
   462
    case 'noop':
7906fb190fc1 Implemented all security features on theme disabling and ACLs; added clean_key mode to login API to clean unused encryption keys
Dan
parents: 461
diff changeset
   463
      break;
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   464
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   465
}
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   466
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   467
/*
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   468
 * RESPONSE HANDLERS
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   469
 */
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   470
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   471
/**
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   472
 * Builds the login form.
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   473
 * @param object Metadata to build off of
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   474
 */
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   475
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   476
window.ajaxLoginBuildForm = function(data)
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   477
{
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   478
  // let's hope this effectively preloads the image...
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   479
  var _ = document.createElement('img');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   480
  _.src = ( ajax_login_successimg_path ) ? ajax_login_successimg_path : scriptPath + '/images/check.png';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   481
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   482
  var div = document.createElement('div');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   483
  div.id = 'ajax_login_form';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   484
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   485
  var show_captcha = ( data.locked_out && data.lockout_info.lockout_policy == 'captcha' ) ? data.lockout_info.captcha : false;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   486
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   487
  // text displayed on re-auth
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   488
  if ( logindata.user_level > USER_LEVEL_MEMBER )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   489
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   490
    div.innerHTML += $lang.get('user_login_ajax_prompt_body_elev') + '<br /><br />';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   491
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   492
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   493
  // Create the form
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   494
  var form = document.createElement('form');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   495
  form.action = 'javascript:void(ajaxLoginSubmitForm());';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   496
  form.onsubmit = function()
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   497
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   498
    ajaxLoginSubmitForm();
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   499
    return false;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   500
  }
460
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   501
  if ( IE )
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   502
  {
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   503
    form.style.marginTop = '-20px';
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   504
  }
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   505
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   506
  // Using tables to wrap form elements because it results in a
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   507
  // more visually appealing form. Yes, tables suck. I don't really
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   508
  // care - they make forms look good.
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   509
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   510
  var table = document.createElement('table');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   511
  table.style.margin = '0 auto';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   512
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   513
  // Field - username
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   514
  var tr1 = document.createElement('tr');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   515
  var td1_1 = document.createElement('td');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   516
  td1_1.appendChild(document.createTextNode($lang.get('user_login_field_username') + ':'));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   517
  tr1.appendChild(td1_1);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   518
  var td1_2 = document.createElement('td');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   519
  var f_username = document.createElement('input');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   520
  f_username.id = 'ajax_login_field_username';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   521
  f_username.name = 'ajax_login_field_username';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   522
  f_username.type = 'text';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   523
  f_username.size = '25';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   524
  if ( data.username )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   525
    f_username.value = data.username;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   526
  td1_2.appendChild(f_username);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   527
  tr1.appendChild(td1_2);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   528
  table.appendChild(tr1);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   529
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   530
  // Field - password
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   531
  var tr2 = document.createElement('tr');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   532
  var td2_1 = document.createElement('td');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   533
  td2_1.appendChild(document.createTextNode($lang.get('user_login_field_password') + ':'));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   534
  tr2.appendChild(td2_1);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   535
  var td2_2 = document.createElement('td');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   536
  var f_password = document.createElement('input');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   537
  f_password.id = 'ajax_login_field_password';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   538
  f_password.name = 'ajax_login_field_username';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   539
  f_password.type = 'password';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   540
  f_password.size = '25';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   541
  if ( !show_captcha )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   542
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   543
    f_password.onkeyup = function(e)
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   544
    {
461
717e71109645 Fixed a number of IE6 bugs
Dan
parents: 460
diff changeset
   545
      if ( !e )
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   546
        e = window.event;
461
717e71109645 Fixed a number of IE6 bugs
Dan
parents: 460
diff changeset
   547
      if ( !e && IE )
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   548
        return true;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   549
      if ( e.keyCode == 13 )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   550
      {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   551
        ajaxLoginSubmitForm();
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   552
      }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   553
    }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   554
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   555
  td2_2.appendChild(f_password);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   556
  tr2.appendChild(td2_2);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   557
  table.appendChild(tr2);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   558
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   559
  // Field - captcha
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   560
  if ( show_captcha )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   561
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   562
    var tr3 = document.createElement('tr');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   563
    var td3_1 = document.createElement('td');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   564
    td3_1.appendChild(document.createTextNode($lang.get('user_login_field_captcha') + ':'));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   565
    tr3.appendChild(td3_1);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   566
    var td3_2 = document.createElement('td');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   567
    var f_captcha = document.createElement('input');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   568
    f_captcha.id = 'ajax_login_field_captcha';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   569
    f_captcha.name = 'ajax_login_field_username';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   570
    f_captcha.type = 'text';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   571
    f_captcha.size = '25';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   572
    f_captcha.onkeyup = function(e)
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   573
    {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   574
      if ( !e )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   575
        e = window.event;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   576
      if ( !e.keyCode )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   577
        return true;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   578
      if ( e.keyCode == 13 )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   579
      {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   580
        ajaxLoginSubmitForm();
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   581
      }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   582
    }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   583
    td3_2.appendChild(f_captcha);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   584
    tr3.appendChild(td3_2);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   585
    table.appendChild(tr3);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   586
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   587
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   588
  // Done building the main part of the form
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   589
  form.appendChild(table);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   590
  
688
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   591
  // Field: remember login
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   592
  if ( logindata.user_level <= USER_LEVEL_MEMBER )
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   593
  {
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   594
    var lbl_remember = document.createElement('label');
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   595
    lbl_remember.style.fontSize = 'smaller';
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   596
    lbl_remember.style.display = 'block';
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   597
    lbl_remember.style.textAlign = 'center';
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   598
    
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   599
    // figure out what text to put in the "remember me" checkbox
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   600
    // infinite session length?
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   601
    if ( data.extended_time == 0 )
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   602
    {
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   603
      // yes, infinite
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   604
      var txt_remember = $lang.get('user_login_ajax_check_remember_infinite');
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   605
    }
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   606
    else
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   607
    {
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   608
      if ( data.extended_time % 7 == 0 )
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   609
      {
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   610
        // number of days is a multiple of 7
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   611
        // use weeks as our unit
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   612
        var sess_time = data.extended_time / 7;
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   613
        var unit = 'week';
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   614
      }
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   615
      else
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   616
      {
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   617
        // use days as our unit
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   618
        var sess_time = data.extended_time;
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   619
        var unit = 'day';
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   620
      }
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   621
      // more than one week or day?
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   622
      if ( sess_time != 1 )
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   623
        unit += 's';
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   624
      
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   625
      // assemble the string
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   626
      var txt_remember = $lang.get('user_login_ajax_check_remember', {
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   627
          session_length: sess_time,
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   628
          length_units: $lang.get('etc_unit_' + unit)
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   629
        });
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   630
    }
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   631
    var check_remember = document.createElement('input');
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   632
    check_remember.type = 'checkbox';
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   633
    // this onclick attribute changes the cookie whenever the checkbox or label is clicked
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   634
    check_remember.setAttribute('onclick', 'var ck = ( this.checked ) ? "enable" : "disable"; createCookie("login_remember", ck, 3650);');
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   635
    if ( readCookie('login_remember') != 'disable' )
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   636
      check_remember.setAttribute('checked', 'checked');
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   637
    check_remember.id = 'ajax_login_field_remember';
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   638
    lbl_remember.appendChild(check_remember);
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   639
    lbl_remember.innerHTML += ' ' + txt_remember;
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   640
    
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   641
    form.appendChild(lbl_remember);
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   642
  }
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   643
  
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   644
  // Field: enable Diffie Hellman
509
175df10e0b56 Added a copy of Firebug Lite for debugging purposes. License is uncertain but being treated as MPL. (If is is not MPL then it is under something more permissive that permits relicensing anyway)
Dan
parents: 478
diff changeset
   645
  if ( IE || is_iPhone )
460
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   646
  {
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   647
    var lbl_dh = document.createElement('span');
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   648
    lbl_dh.style.fontSize = 'smaller';
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   649
    lbl_dh.style.display = 'block';
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   650
    lbl_dh.style.textAlign = 'center';
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   651
    lbl_dh.innerHTML = $lang.get('user_login_ajax_check_dh_ie');
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   652
    form.appendChild(lbl_dh);
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   653
  }
718
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   654
  else if ( !data.allow_diffiehellman )
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   655
  {
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   656
    // create hidden control - server requested that DiffieHellman be disabled (usually means not supported)
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   657
    var check_dh = document.createElement('input');
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   658
    check_dh.type = 'hidden';
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   659
    check_dh.id = 'ajax_login_field_dh';
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   660
    form.appendChild(check_dh);
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   661
  }
460
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   662
  else
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   663
  {
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   664
    var lbl_dh = document.createElement('label');
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   665
    lbl_dh.style.fontSize = 'smaller';
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   666
    lbl_dh.style.display = 'block';
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   667
    lbl_dh.style.textAlign = 'center';
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   668
    var check_dh = document.createElement('input');
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   669
    check_dh.type = 'checkbox';
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   670
    // this onclick attribute changes the cookie whenever the checkbox or label is clicked
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   671
    check_dh.setAttribute('onclick', 'var ck = ( this.checked ) ? "enable" : "disable"; createCookie("diffiehellman_login", ck, 3650);');
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   672
    if ( readCookie('diffiehellman_login') != 'disable' )
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   673
      check_dh.setAttribute('checked', 'checked');
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   674
    check_dh.id = 'ajax_login_field_dh';
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   675
    lbl_dh.appendChild(check_dh);
694
43367c66d869 Couple of fixes (hacks) for Opera and the aftermath of that z-index change to darken() and enlighten() fadefilters; added ajaxOpenDirectACLRule() to placeholder list
Dan
parents: 688
diff changeset
   676
    lbl_dh.innerHTML += ' ' + $lang.get('user_login_ajax_check_dh');
460
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   677
    form.appendChild(lbl_dh);
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   678
  }
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   679
  
460
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   680
  if ( IE )
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   681
  {
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   682
    div.innerHTML += form.outerHTML;
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   683
  }
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   684
  else
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   685
  {
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   686
    div.appendChild(form);
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   687
  }
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   688
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   689
  // Diagnostic / help links
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   690
  // (only displayed in login, not in re-auth)
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   691
  if ( logindata.user_level == USER_LEVEL_MEMBER )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   692
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   693
    form.style.marginBottom = '10px';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   694
    var links = document.createElement('small');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   695
    links.style.display = 'block';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   696
    links.style.textAlign = 'center';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   697
    links.innerHTML = '';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   698
    if ( !show_captcha )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   699
      links.innerHTML += $lang.get('user_login_ajax_link_fullform', { link_full_form: makeUrlNS('Special', 'Login/' + title) }) + '<br />';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   700
    // Always shown
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   701
    links.innerHTML += $lang.get('user_login_ajax_link_forgotpass', { forgotpass_link: makeUrlNS('Special', 'PasswordReset') }) + '<br />';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   702
    if ( !show_captcha )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   703
      links.innerHTML += $lang.get('user_login_createaccount_blurb', { reg_link: makeUrlNS('Special', 'Register') });
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   704
    div.appendChild(links);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   705
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   706
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   707
  // Insert the entire form into the login window
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   708
  logindata.mb_inner.innerHTML = '';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   709
  logindata.mb_inner.appendChild(div);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   710
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   711
  // Post operations: field focus
816
44b8446533e1 Fixed login form being focused too early (caused page to scroll up)
Dan
parents: 811
diff changeset
   712
  setTimeout(
44b8446533e1 Fixed login form being focused too early (caused page to scroll up)
Dan
parents: 811
diff changeset
   713
    function()
44b8446533e1 Fixed login form being focused too early (caused page to scroll up)
Dan
parents: 811
diff changeset
   714
    {
44b8446533e1 Fixed login form being focused too early (caused page to scroll up)
Dan
parents: 811
diff changeset
   715
      if ( logindata.loggedin_username )
44b8446533e1 Fixed login form being focused too early (caused page to scroll up)
Dan
parents: 811
diff changeset
   716
        document.getElementById('ajax_login_field_password').focus();
44b8446533e1 Fixed login form being focused too early (caused page to scroll up)
Dan
parents: 811
diff changeset
   717
      else
44b8446533e1 Fixed login form being focused too early (caused page to scroll up)
Dan
parents: 811
diff changeset
   718
        document.getElementById('ajax_login_field_username').focus();
44b8446533e1 Fixed login form being focused too early (caused page to scroll up)
Dan
parents: 811
diff changeset
   719
    }, 750);        
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   720
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   721
  // Post operations: show captcha window
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   722
  if ( show_captcha )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   723
    ajaxShowCaptcha(show_captcha);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   724
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   725
  // Post operations: stash encryption keys and All That Jazz(TM)
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   726
  logindata.key_aes = data.aes_key;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   727
  logindata.key_dh = data.dh_public_key;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   728
  logindata.captcha_hash = show_captcha;
460
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   729
  logindata.loggedin_username = data.username
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   730
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   731
  // Are we locked out? If so simulate an error and disable the controls
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   732
  if ( data.lockout_info.lockout_policy == 'lockout' && data.locked_out )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   733
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   734
    f_username.setAttribute('disabled', 'disabled');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   735
    f_password.setAttribute('disabled', 'disabled');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   736
    var fake_packet = {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   737
      error_code: 'locked_out',
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   738
      respawn_info: data
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   739
    };
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   740
    ajaxLoginShowFriendlyError(fake_packet);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   741
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   742
}
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   743
688
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   744
window.ajaxLoginSubmitForm = function(real, username, password, captcha, remember)
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   745
{
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   746
  // Perform AES test to make sure it's all working
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   747
  if ( !aes_self_test() )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   748
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   749
    alert('BUG: AES self-test failed');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   750
    login_cache.mb_object.destroy();
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   751
    return false;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   752
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   753
  // Hide the error message and captcha
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   754
  if ( document.getElementById('ajax_login_error_box') )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   755
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   756
    document.getElementById('ajax_login_error_box').parentNode.removeChild(document.getElementById('ajax_login_error_box'));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   757
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   758
  if ( document.getElementById('autoCaptcha') )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   759
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   760
    var to = fly_out_top(document.getElementById('autoCaptcha'), false, true);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   761
    setTimeout(function() {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   762
        var d = document.getElementById('autoCaptcha');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   763
        d.parentNode.removeChild(d);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   764
      }, to);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   765
  }
688
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   766
  // "Remember session" switch
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   767
  if ( typeof(remember) == 'boolean' )
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   768
  {
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   769
    var remember_session = remember;
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   770
  }
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   771
  else
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   772
  {
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   773
    if ( document.getElementById('ajax_login_field_remember') )
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   774
    {
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   775
      var remember_session = ( document.getElementById('ajax_login_field_remember').checked ) ? true : false;
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   776
    }
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   777
    else
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   778
    {
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   779
      var remember_session = false;
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   780
    }
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   781
  }
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   782
  // Encryption: preprocessor
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   783
  if ( real )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   784
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   785
    var do_dh = true;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   786
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   787
  else if ( document.getElementById('ajax_login_field_dh') )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   788
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   789
    var do_dh = document.getElementById('ajax_login_field_dh').checked;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   790
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   791
  else
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   792
  {
509
175df10e0b56 Added a copy of Firebug Lite for debugging purposes. License is uncertain but being treated as MPL. (If is is not MPL then it is under something more permissive that permits relicensing anyway)
Dan
parents: 478
diff changeset
   793
    if ( IE || is_iPhone )
460
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   794
    {
509
175df10e0b56 Added a copy of Firebug Lite for debugging purposes. License is uncertain but being treated as MPL. (If is is not MPL then it is under something more permissive that permits relicensing anyway)
Dan
parents: 478
diff changeset
   795
      // IE/MobileSafari doesn't have this control, continue silently IF the rest
460
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   796
      // of the login form is there
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   797
      if ( !document.getElementById('ajax_login_field_username') )
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   798
      {
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   799
        return false;
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   800
      }
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   801
    }
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   802
    else
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   803
    {
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   804
      // The user probably clicked ok when the form wasn't in there.
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   805
      return false;
3a1c99845ca8 Merging in changes from Nighthawk
Dan
parents: 436
diff changeset
   806
    }
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   807
  }
718
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   808
  
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   809
  if ( !username )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   810
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   811
    var username = document.getElementById('ajax_login_field_username').value;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   812
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   813
  if ( !password )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   814
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   815
    var password = document.getElementById('ajax_login_field_password').value;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   816
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   817
  if ( !captcha && document.getElementById('ajax_login_field_captcha') )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   818
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   819
    var captcha = document.getElementById('ajax_login_field_captcha').value;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   820
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   821
  
718
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   822
  try
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   823
  {
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   824
  
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   825
  if ( do_dh )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   826
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   827
    ajaxLoginSetStatus(AJAX_STATUS_GENERATING_KEY);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   828
    if ( !real )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   829
    {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   830
      // Wait while the browser updates the login window
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   831
      setTimeout(function()
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   832
        {
688
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   833
          ajaxLoginSubmitForm(true, username, password, captcha, remember_session);
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   834
        }, 200);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   835
      return true;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   836
    }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   837
    // Perform Diffie Hellman stuff
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   838
    var dh_priv = dh_gen_private();
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   839
    var dh_pub = dh_gen_public(dh_priv);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   840
    var secret = dh_gen_shared_secret(dh_priv, logindata.key_dh);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   841
    // secret_hash is used to verify that the server guesses the correct secret
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   842
    var secret_hash = hex_sha1(secret);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   843
    // crypt_key is the actual AES key
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   844
    var crypt_key = (hex_sha256(secret)).substr(0, (keySizeInBits / 4));
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   845
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   846
  else
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   847
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   848
    var crypt_key = logindata.key_aes;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   849
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   850
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   851
  ajaxLoginSetStatus(AJAX_STATUS_LOGGING_IN);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   852
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   853
  // Encrypt the password and username
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   854
  var userinfo = toJSONString({
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   855
      username: username,
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   856
      password: password
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   857
    });
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   858
  var crypt_key_ba = hexToByteArray(crypt_key);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   859
  userinfo = stringToByteArray(userinfo);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   860
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   861
  userinfo = rijndaelEncrypt(userinfo, crypt_key_ba, 'ECB');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   862
  userinfo = byteArrayToHex(userinfo);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   863
  // Encrypted username and password (serialized with JSON) are now in the userinfo string
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   864
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   865
  // Collect other needed information
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   866
  if ( logindata.captcha_hash )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   867
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   868
    var captcha_hash = logindata.captcha_hash;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   869
    var captcha_code = captcha;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   870
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   871
  else
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   872
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   873
    var captcha_hash = false;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   874
    var captcha_code = false;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   875
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   876
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   877
  // Ship it across the 'net
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   878
  if ( do_dh )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   879
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   880
    var json_packet = {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   881
      mode: 'login_dh',
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   882
      userinfo: userinfo,
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   883
      captcha_code: captcha_code,
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   884
      captcha_hash: captcha_hash,
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   885
      dh_public_key: logindata.key_dh,
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   886
      dh_client_key: dh_pub,
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   887
      dh_secret_hash: secret_hash,
688
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   888
      level: logindata.user_level,
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   889
      remember: remember_session
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   890
    }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   891
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   892
  else
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   893
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   894
    var json_packet = {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   895
      mode: 'login_aes',
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   896
      userinfo: userinfo,
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   897
      captcha_code: captcha_code,
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   898
      captcha_hash: captcha_hash,
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   899
      key_aes: hex_md5(crypt_key),
688
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   900
      level: logindata.user_level,
f2a824ce5f18 Added customizable parameters for session length and the long-missing "remember me" option (or rather, the ability to turn it off and make sessions temporary)
Dan
parents: 651
diff changeset
   901
      remember: remember_session
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   902
    }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   903
  }
718
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   904
  }
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   905
  catch(e)
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   906
  {
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   907
    ajaxLoginSetStatus(AJAX_STATUS_ERROR);
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   908
    console.error('Exception caught in login process; backtrace follows');
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   909
    console.debug(e);
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   910
    return false;
12485b1d41fd Fixed issue where login box was not obeying server orders to disable DiffieHellman. Increased quality of error handling for JS errors during login process.
Dan
parents: 699
diff changeset
   911
  }
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   912
  ajaxLoginPerformRequest(json_packet);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   913
}
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   914
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   915
window.ajaxLoginShowFriendlyError = function(response)
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   916
{
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   917
  if ( !response.respawn_info )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   918
    return false;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   919
  if ( !response.error_code )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   920
    return false;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   921
  var text = ajaxLoginGetErrorText(response);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   922
  if ( document.getElementById('ajax_login_error_box') )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   923
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   924
    // console.info('Reusing existing error-box');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   925
    document.getElementById('ajax_login_error_box').innerHTML = text;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   926
    return true;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   927
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   928
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   929
  // console.info('Drawing new error-box');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   930
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   931
  // calculate position for the top of the box
699
c7d737202d59 Removed Adobe Spry and replaced with jQuery. Please report any new bugs on the forums or via IRC. In a related note, auto-completion should work now at least for usernames. Still hacking away at page name completion...
Dan
parents: 694
diff changeset
   932
  var mb_bottom = $dynano('messageBoxButtons').Top() + $dynano('messageBoxButtons').Height();
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   933
  // if the box isn't done flying in yet, just estimate
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   934
  if ( mb_bottom < ( getHeight() / 2 ) )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   935
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   936
    mb_bottom = ( getHeight() / 2 ) + 120;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   937
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   938
  var win_bottom = getHeight() + getScrollOffset();
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   939
  var top = mb_bottom + ( ( win_bottom - mb_bottom ) / 2 ) - 32;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   940
  // left position = 0.2 * window_width, seeing as the box is 60% width this works hackishly but nice and quick
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   941
  var left = getWidth() * 0.2;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   942
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   943
  // create the div
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   944
  var errbox = document.createElement('div');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   945
  errbox.className = 'error-box-mini';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   946
  errbox.style.position = 'absolute';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   947
  errbox.style.width = '60%';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   948
  errbox.style.top = top + 'px';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   949
  errbox.style.left = left + 'px';
694
43367c66d869 Couple of fixes (hacks) for Opera and the aftermath of that z-index change to darken() and enlighten() fadefilters; added ajaxOpenDirectACLRule() to placeholder list
Dan
parents: 688
diff changeset
   950
  errbox.style.zIndex = getHighestZ();
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   951
  errbox.innerHTML = text;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   952
  errbox.id = 'ajax_login_error_box';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   953
  
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   954
  var body = document.getElementsByTagName('body')[0];
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   955
  body.appendChild(errbox);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   956
}
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   957
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
   958
window.ajaxLoginGetErrorText = function(response)
436
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   959
{
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   960
  switch ( response.error_code )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   961
  {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   962
    default:
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   963
      return $lang.get('user_err_' + response.error_code);
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   964
      break;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   965
    case 'locked_out':
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   966
      if ( response.respawn_info.lockout_info.lockout_policy == 'lockout' )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   967
      {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   968
        return $lang.get('user_err_locked_out', { 
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   969
                  lockout_threshold: response.respawn_info.lockout_info.lockout_threshold,
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   970
                  lockout_duration: response.respawn_info.lockout_info.lockout_duration,
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   971
                  time_rem: response.respawn_info.lockout_info.time_rem,
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   972
                  plural: ( response.respawn_info.lockout_info.time_rem == 1 ) ? '' : $lang.get('meta_plural'),
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   973
                  captcha_blurb: ''
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   974
                });
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   975
        break;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   976
      }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   977
    case 'invalid_credentials':
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   978
      var base = $lang.get('user_err_invalid_credentials');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   979
      if ( response.respawn_info.locked_out )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   980
      {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   981
        base += ' ';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   982
        var captcha_blurb = '';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   983
        switch(response.respawn_info.lockout_info.lockout_policy)
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   984
        {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   985
          case 'captcha':
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   986
            captcha_blurb = $lang.get('user_err_locked_out_captcha_blurb');
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   987
            break;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   988
          case 'lockout':
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   989
            break;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   990
          default:
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   991
            base += 'WTF? Shouldn\'t be locked out with lockout policy set to disable.';
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   992
            break;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   993
        }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   994
        base += $lang.get('user_err_locked_out', { 
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   995
                  captcha_blurb: captcha_blurb,
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   996
                  lockout_threshold: response.respawn_info.lockout_info.lockout_threshold,
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   997
                  lockout_duration: response.respawn_info.lockout_info.lockout_duration,
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   998
                  time_rem: response.respawn_info.lockout_info.time_rem,
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
   999
                  plural: ( response.respawn_info.lockout_info.time_rem == 1 ) ? '' : $lang.get('meta_plural')
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1000
                });
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1001
      }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1002
      else if ( response.respawn_info.lockout_info.lockout_policy == 'lockout' || response.respawn_info.lockout_info.lockout_policy == 'captcha' )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1003
      {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1004
        // if we have a lockout policy of captcha or lockout, then warn the user
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1005
        switch ( response.respawn_info.lockout_info.lockout_policy )
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1006
        {
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1007
          case 'captcha':
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1008
            base += $lang.get('user_err_invalid_credentials_lockout', { 
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1009
                fails: response.respawn_info.lockout_info.lockout_fails,
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1010
                lockout_threshold: response.respawn_info.lockout_info.lockout_threshold,
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1011
                lockout_duration: response.respawn_info.lockout_info.lockout_duration
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1012
              });
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1013
            break;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1014
          case 'lockout':
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1015
            break;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1016
        }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1017
      }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1018
      return base;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1019
      break;
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1020
  }
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1021
}
242353360e37 Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
diff changeset
  1022
585
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1023
window.ajaxShowCaptcha = function(code)
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1024
{
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1025
  var mydiv = document.createElement('div');
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1026
  mydiv.style.backgroundColor = '#FFFFFF';
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1027
  mydiv.style.padding = '10px';
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1028
  mydiv.style.position = 'absolute';
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1029
  mydiv.style.top = '0px';
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1030
  mydiv.id = 'autoCaptcha';
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1031
  mydiv.style.zIndex = String( getHighestZ() + 1 );
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1032
  var img = document.createElement('img');
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1033
  img.onload = function()
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1034
  {
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1035
    if ( this.loaded )
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1036
      return true;
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1037
    var mydiv = document.getElementById('autoCaptcha');
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1038
    var width = getWidth();
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1039
    var divw = $dynano(mydiv).Width();
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1040
    var left = ( width / 2 ) - ( divw / 2 );
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1041
    mydiv.style.left = left + 'px';
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1042
    fly_in_top(mydiv, false, true);
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1043
    this.loaded = true;
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1044
  };
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1045
  img.src = makeUrlNS('Special', 'Captcha/' + code);
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1046
  img.onclick = function() { this.src = this.src + '/a'; };
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1047
  img.style.cursor = 'pointer';
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1048
  mydiv.appendChild(img);
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1049
  domObjChangeOpac(0, mydiv);
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1050
  var body = document.getElementsByTagName('body')[0];
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1051
  body.appendChild(mydiv);
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1052
}
35e91d16ecf5 Fixed javascript ACL manager and captcha not showing on ajax login lockout_captcha event
Dan
parents: 582
diff changeset
  1053
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1054
window.ajaxInitLogout = function()
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1055
{
779
609e35845ec3 load_component() now accepts an array, and most JS components are loaded all in one request now. Totally modular baby. And failsafe too.
Dan
parents: 741
diff changeset
  1056
  load_component(['messagebox', 'l10n', 'flyin', 'fadefilter']);
582
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1057
  var mb = new MessageBox(MB_YESNO|MB_ICONQUESTION, $lang.get('user_logout_confirm_title'), $lang.get('user_logout_confirm_body'));
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1058
  mb.onclick['Yes'] = function()
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1059
    {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1060
      window.location = makeUrlNS('Special', 'Logout/' + csrf_token + '/' + title);
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1061
    }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1062
}
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1063
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1064
window.mb_logout = function()
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1065
{
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1066
  ajaxInitLogout();
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1067
}
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1068
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1069
window.ajaxStartLogin = function()
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1070
{
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1071
  ajaxLogonToMember();
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1072
}
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1073
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1074
window.ajaxStartAdminLogin = function()
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1075
{
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1076
  // IE <6 pseudo-compatibility
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1077
  if ( KILL_SWITCH )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1078
    return true;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1079
  if ( auth_level < USER_LEVEL_ADMIN )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1080
  {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1081
    ajaxLoginInit(function(k) {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1082
      ENANO_SID = k;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1083
      auth_level = USER_LEVEL_ADMIN;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1084
      var loc = makeUrlNS('Special', 'Administration');
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1085
      if ( (ENANO_SID + ' ').length > 1 )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1086
        window.location = loc;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1087
    }, USER_LEVEL_ADMIN);
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1088
    return false;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1089
  }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1090
  var loc = makeUrlNS('Special', 'Administration');
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1091
  window.location = loc;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1092
}
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1093
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1094
window.ajaxAdminPage = function()
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1095
{
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1096
  // IE <6 pseudo-compatibility
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1097
  if ( KILL_SWITCH )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1098
    return true;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1099
  if ( auth_level < USER_LEVEL_ADMIN )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1100
  {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1101
    ajaxPromptAdminAuth(function(k) {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1102
      ENANO_SID = k;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1103
      auth_level = USER_LEVEL_ADMIN;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1104
      var loc = String(window.location + '');
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1105
      window.location = append_sid(loc);
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1106
      var loc = makeUrlNS('Special', 'Administration', 'module=' + namespace_list['Admin'] + 'PageManager&source=ajax&page_id=' + ajaxEscape(title));
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1107
      if ( (ENANO_SID + ' ').length > 1 )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1108
        window.location = loc;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1109
    }, 9);
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1110
    return false;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1111
  }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1112
  var loc = makeUrlNS('Special', 'Administration', 'module=' + namespace_list['Admin'] + 'PageManager&source=ajax&page_id=' + ajaxEscape(title));
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1113
  window.location = loc;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1114
}
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1115
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1116
var navto_ns;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1117
var navto_pg;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1118
var navto_ul;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1119
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1120
window.ajaxLoginNavTo = function(namespace, page_id, min_level)
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1121
{
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1122
  // IE <6 pseudo-compatibility
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1123
  if ( KILL_SWITCH )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1124
    return true;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1125
  navto_pg = page_id;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1126
  navto_ns = namespace;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1127
  navto_ul = min_level;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1128
  if ( auth_level < min_level )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1129
  {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1130
    ajaxPromptAdminAuth(function(k) {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1131
      ENANO_SID = k;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1132
      auth_level = navto_ul;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1133
      var loc = makeUrlNS(navto_ns, navto_pg);
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1134
      if ( (ENANO_SID + ' ').length > 1 )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1135
        window.location = loc;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1136
    }, min_level);
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1137
    return false;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1138
  }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1139
  var loc = makeUrlNS(navto_ns, navto_pg);
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1140
  window.location = loc;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1141
}
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1142
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1143
window.ajaxAdminUser = function(username)
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1144
{
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1145
  // IE <6 pseudo-compatibility
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1146
  if ( KILL_SWITCH )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1147
    return true;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1148
  if ( auth_level < USER_LEVEL_ADMIN )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1149
  {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1150
    ajaxPromptAdminAuth(function(k) {
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1151
      ENANO_SID = k;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1152
      auth_level = USER_LEVEL_ADMIN;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1153
      var loc = String(window.location + '');
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1154
      window.location = append_sid(loc);
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1155
      var loc = makeUrlNS('Special', 'Administration', 'module=' + namespace_list['Admin'] + 'UserManager&src=get&user=' + ajaxEscape(username));
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1156
      if ( (ENANO_SID + ' ').length > 1 )
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1157
        window.location = loc;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1158
    }, 9);
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1159
    return false;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1160
  }
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1161
  var loc = makeUrlNS('Special', 'Administration', 'module=' + namespace_list['Admin'] + 'UserManager&src=get&user=' + ajaxEscape(username));
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1162
  window.location = loc;
a38876c0793c Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents: 550
diff changeset
  1163
}
793
c0724bf6039b Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
parents: 780
diff changeset
  1164
811
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1165
window.ajaxDynamicReauth = function(adminpage, level)
793
c0724bf6039b Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
parents: 780
diff changeset
  1166
{
c0724bf6039b Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
parents: 780
diff changeset
  1167
  var old_sid = ENANO_SID;
c0724bf6039b Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
parents: 780
diff changeset
  1168
  var targetpage = adminpage;
811
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1169
  if ( !level )
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1170
  {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1171
    level = USER_LEVEL_ADMIN;
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1172
  }
793
c0724bf6039b Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
parents: 780
diff changeset
  1173
  ajaxLogonInit(function(k)
c0724bf6039b Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
parents: 780
diff changeset
  1174
    {
811
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1175
      ajaxLoginReplaceSIDInline(k, old_sid, level);
794
720516162012 Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
parents: 793
diff changeset
  1176
      mb_current_obj.destroy();
720516162012 Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
parents: 793
diff changeset
  1177
      console.debug(targetpage);
720516162012 Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
parents: 793
diff changeset
  1178
      if ( typeof(targetpage) == 'string' )
793
c0724bf6039b Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
parents: 780
diff changeset
  1179
      {
c0724bf6039b Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
parents: 780
diff changeset
  1180
        ajaxPage(targetpage);
c0724bf6039b Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
parents: 780
diff changeset
  1181
      }
794
720516162012 Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
parents: 793
diff changeset
  1182
      else if ( typeof(targetpage) == 'function' )
720516162012 Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
parents: 793
diff changeset
  1183
      {
720516162012 Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
parents: 793
diff changeset
  1184
        targetpage();
720516162012 Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
parents: 793
diff changeset
  1185
      }
811
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1186
    }, level);
793
c0724bf6039b Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
parents: 780
diff changeset
  1187
  ajaxLoginShowFriendlyError({
c0724bf6039b Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
parents: 780
diff changeset
  1188
      error_code: 'admin_session_timed_out',
c0724bf6039b Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
parents: 780
diff changeset
  1189
      respawn_info: {}
c0724bf6039b Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
parents: 780
diff changeset
  1190
  });
c0724bf6039b Added dynamic reload-less re-auth to admin panel, so that if a session is lost it can be recovered without a reload. Support for hooking into form submits will be added in the future.
Dan
parents: 780
diff changeset
  1191
}
794
720516162012 Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
parents: 793
diff changeset
  1192
720516162012 Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
parents: 793
diff changeset
  1193
window.ajaxRenewSession = function()
720516162012 Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
parents: 793
diff changeset
  1194
{
720516162012 Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
parents: 793
diff changeset
  1195
  ajaxDynamicReauth(false);
720516162012 Added support for re-auth on submit to rank manager when session goes bad; still more to come
Dan
parents: 793
diff changeset
  1196
}
811
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1197
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1198
window.ajaxTrashElevSession = function()
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1199
{
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1200
  load_component(['messagebox', 'fadefilter', 'l10n', 'flyin', 'jquery', 'jquery-ui']);
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1201
  miniPromptMessage({
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1202
    title: $lang.get('user_logout_confirm_title_elev'),
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1203
    message: $lang.get('user_logout_confirm_body_elev'),
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1204
    buttons: [
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1205
      {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1206
        text: $lang.get('user_logout_confirm_btn_logout'),
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1207
        color: 'red',
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1208
        style: {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1209
          fontWeight: 'bold'
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1210
        },
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1211
        onclick: function()
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1212
        {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1213
          ajaxLoginPerformRequest({
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1214
              mode:  'logout',
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1215
              level: auth_level,
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1216
              csrf_token: csrf_token
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1217
          });
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1218
          miniPromptDestroy(this);
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1219
        }
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1220
      },
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1221
      {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1222
        text: $lang.get('etc_cancel'),
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1223
        onclick: function()
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1224
        {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1225
          miniPromptDestroy(this);
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1226
        }
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1227
      }
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1228
    ]
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1229
  });
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1230
}
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1231
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1232
/**
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1233
 * Take an SID and patch all internal links on the page.
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1234
 * @param string New key. If false, removes keys from the page.
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1235
 * @param string Old key. If false, only appends the new SID (more work as it uses DOM, use when dynamically going up to elevated)
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1236
 * @param int New level, not a huge deal but sets auth_level. Try to specify it as some functions depend on it.
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1237
 */
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1238
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1239
window.ajaxLoginReplaceSIDInline = function(key, oldkey, level)
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1240
{
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1241
  var host = String(window.location.hostname);
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1242
  var exp = new RegExp('^https?://' + host.replace('.', '\.') + contentPath.replace('.', '\.'), 'g');
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1243
  var rexp = new RegExp('^https?://' + host.replace('.', '\.'), 'g');
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1244
  
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1245
  if ( key )
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1246
  {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1247
    if ( oldkey )
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1248
    {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1249
      var body = document.getElementsByTagName('body')[0];
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1250
      var replace = new RegExp(oldkey, 'g');
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1251
      body.innerHTML = body.innerHTML.replace(replace, key);
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1252
      ENANO_SID = key;
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1253
    }
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1254
    else
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1255
    {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1256
      // append SID to all internal links
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1257
      ENANO_SID = key;
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1258
      
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1259
      var links = document.getElementsByTagName('a');
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1260
      for ( var i = 0; i < links.length; i++ )
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1261
      {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1262
        if ( links[i].href.match(exp, links[i]) && links[i].href.indexOf('#') == -1 )
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1263
        {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1264
          var newurl = (String(append_sid(links[i].href))).replace(rexp, '');
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1265
          links[i].href = newurl;
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1266
        }
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1267
      }
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1268
      
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1269
      var forms = document.getElementsByTagName('form');
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1270
      for ( var i = 0; i < forms.length; i++ )
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1271
      {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1272
        if ( forms[i].method.toLowerCase() == 'post' )
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1273
        {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1274
          if ( forms[i].action.match(exp, links[i]) )
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1275
          {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1276
            var newurl = (String(append_sid(forms[i].action))).replace(rexp, '');
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1277
            forms[i].action = newurl;
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1278
          }
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1279
        }
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1280
        else
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1281
        {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1282
          if ( !forms[i].auth )
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1283
          {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1284
            var auth = document.createElement('input');
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1285
            auth.type = 'hidden';
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1286
            auth.name = 'auth';
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1287
            auth.value = key;
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1288
            forms[i].appendChild(auth);
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1289
          }
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1290
          else
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1291
          {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1292
            forms[i].auth.value = key;
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1293
          }
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1294
        }
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1295
      }
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1296
    }
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1297
    if ( level )
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1298
    {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1299
      auth_level = level;
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1300
    }
824
28d9fbcd4f0d Login: reauth: window.location.hash is now updated to include the new SID so that page reloads will use it
Dan
parents: 816
diff changeset
  1301
    window.location.hash = '#auth:' + key;
811
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1302
  }
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1303
  else
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1304
  {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1305
    auth_level = USER_LEVEL_MEMBER;
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1306
    ENANO_SID = false;
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1307
    if ( oldkey )
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1308
    {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1309
      var links = document.getElementsByTagName('a');
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1310
      for ( var i = 0; i < links.length; i++ )
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1311
      {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1312
        if ( links[i].href.match(exp, links[i]) && links[i].href.indexOf('#') == -1 )
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1313
        {
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1314
          links[i].href = links[i].href.replace(/\?auth=([a-f0-9]+)(&|#|$)/, '$2').replace(/&auth=([a-f0-9]+)/, '').replace(rexp, '');
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1315
        }
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1316
      }
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1317
    }
824
28d9fbcd4f0d Login: reauth: window.location.hash is now updated to include the new SID so that page reloads will use it
Dan
parents: 816
diff changeset
  1318
    window.location.hash = '#auth:false';
811
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1319
  }
5c807fe77020 Added support for live re-auth and de-auth; fully AJAX, no page reload required, plus plugin-usable API.
Dan
parents: 794
diff changeset
  1320
}