Changeset 4429


Ignore:
Timestamp:
Dec 5, 2009, 8:55:21 PM (14 years ago)
Author:
Eric
Message:

Feature 0000796 fixed : Strengthen login handling

Location:
trunk/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/config_default.inc.php

    r4357 r4429  
    325325// Define using double password type in admin's users management panel
    326326$conf['double_password_type_in_admin'] = false;
     327
     328// Define if logins must be case sentitive or not at users registration. ie :
     329// If set true, the login "user" will equal "User" or "USER" or "user",
     330// etc. ... And it will be impossible to use such login variation to create a
     331// new user account.
     332$conf['no_case_sensitive_for_login'] = false;
    327333
    328334// +-----------------------------------------------------------------------+
  • trunk/include/functions_user.inc.php

    r4385 r4429  
    6767}
    6868
     69// validate_login_case:
     70//   o check if login is not used by a other user
     71// If the login doesn't correspond, an error message is returned.
     72//
     73function validate_login_case($login)
     74{
     75  global $conf;
     76 
     77  if (defined("PHPWG_INSTALLED"))
     78  {
     79    $query = "
     80SELECT ".$conf['user_fields']['username']."
     81FROM ".USERS_TABLE."
     82WHERE LOWER(".stripslashes($conf['user_fields']['username']).") = '".strtolower($login)."'
     83;";
     84
     85    $count = pwg_db_num_rows(pwg_query($query));
     86
     87    if ($count > 0)
     88    {
     89      return l10n('reg_err_login5');
     90    }
     91  }
     92}
     93
    6994function register_user($login, $password, $mail_address,
    7095  $with_notification = true, $errors = array())
     
    92117  {
    93118    array_push($errors, $mail_error);
     119  }
     120
     121  if ($conf['no_case_sensitive_for_login'] == true)
     122  {
     123    $login_error = validate_login_case($login);
     124    if ($login_error != '')
     125    {
     126      array_push($errors, $login_error);
     127    }
    94128  }
    95129
Note: See TracChangeset for help on using the changeset viewer.