Ignore:
Timestamp:
Aug 24, 2011, 10:03:53 PM (13 years ago)
Author:
plg
Message:

feature 2027 implemented: the "lost password" feature was rewritten.

The algorithm is highly inspired from WordPress :

1) in a single field, you give a username or an email
2) Piwigo sends an email with the activation key
3) the user clicks on the link in the email (with the activation key) and is able to set a new password

The "lost password" feature is no longer limited to "classic" users:
administrators and webmasters can use it too (no need to tell webmasters
that they can only change their password in the database)

File:
1 edited

Legend:

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

    r11826 r11992  
    785785  FROM '.USERS_TABLE.'
    786786  WHERE '.$conf['user_fields']['username'].' = \''.$username.'\'
     787;';
     788  $result = pwg_query($query);
     789
     790  if (pwg_db_num_rows($result) == 0)
     791  {
     792    return false;
     793  }
     794  else
     795  {
     796    list($user_id) = pwg_db_fetch_row($result);
     797    return $user_id;
     798  }
     799}
     800
     801function get_userid_by_email($email)
     802{
     803  global $conf;
     804
     805  $email = pwg_db_real_escape_string($email);
     806 
     807  $query = '
     808SELECT
     809    '.$conf['user_fields']['id'].'
     810  FROM '.USERS_TABLE.'
     811  WHERE UPPER('.$conf['user_fields']['email'].') = UPPER(\''.$email.'\')
    787812;';
    788813  $result = pwg_query($query);
     
    14731498}
    14741499
     1500/**
     1501 * search an available activation_key
     1502 *
     1503 * @return string
     1504 */
     1505function get_user_activation_key()
     1506{
     1507  while (true)
     1508  {
     1509    $key = generate_key(20);
     1510    $query = '
     1511SELECT COUNT(*)
     1512  FROM '.USER_INFOS_TABLE.'
     1513  WHERE activation_key = \''.$key.'\'
     1514;';
     1515    list($count) = pwg_db_fetch_row(pwg_query($query));
     1516    if (0 == $count)
     1517    {
     1518      return $key;
     1519    }
     1520  }
     1521}
     1522
    14751523?>
Note: See TracChangeset for help on using the changeset viewer.