|
|
|
@ -24,19 +24,19 @@ require_once '../inc/global.inc.php'; |
|
|
|
|
require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php'; |
|
|
|
|
|
|
|
|
|
// Custom pages |
|
|
|
|
// Had to move the form handling in here, because otherwise there would |
|
|
|
|
// Had to move the form handling in here, because otherwise there would |
|
|
|
|
// already be some display output. |
|
|
|
|
global $_configuration; |
|
|
|
|
|
|
|
|
|
if (CustomPages::enabled()) { |
|
|
|
|
//Reset Password when user goes to the link |
|
|
|
|
if ($_GET['reset'] && $_GET['id']){ |
|
|
|
|
if ($_GET['reset'] && $_GET['id']) { |
|
|
|
|
$mesg = Login::reset_password($_GET["reset"], $_GET["id"], true); |
|
|
|
|
CustomPages::display(CustomPages::INDEX_UNLOGGED, array('info' => $mesg)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//Check email/username and do the right thing |
|
|
|
|
if (isset ($_POST['user']) && isset ($_POST['email'])) { |
|
|
|
|
if (isset($_POST['user']) && isset ($_POST['email'])) { |
|
|
|
|
$user = $_POST['user']; |
|
|
|
|
$email = $_POST['email']; |
|
|
|
|
|
|
|
|
@ -57,16 +57,18 @@ if (CustomPages::enabled()) { |
|
|
|
|
|
|
|
|
|
if ($result && $num_rows > 0) { |
|
|
|
|
if ($num_rows > 1) { |
|
|
|
|
$by_username = false; // more than one user |
|
|
|
|
// more than one user |
|
|
|
|
$by_username = false; |
|
|
|
|
while ($data = Database::fetch_array($result)) { |
|
|
|
|
$user[] = $data; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$by_username = true; // single user (valid user + email) |
|
|
|
|
// single user (valid user + email) |
|
|
|
|
$by_username = true; |
|
|
|
|
$user = Database::fetch_array($result); |
|
|
|
|
} |
|
|
|
|
if ($_configuration['password_encryption'] != 'none') { |
|
|
|
|
//Send email with secret link to user |
|
|
|
|
// Send email with secret link to user |
|
|
|
|
Login::handle_encrypted_password($user, $by_username); |
|
|
|
|
} else { |
|
|
|
|
Login::send_password_to_user($user, $by_username); |
|
|
|
@ -75,9 +77,12 @@ if (CustomPages::enabled()) { |
|
|
|
|
CustomPages::display(CustomPages::LOST_PASSWORD, array('error' => get_lang('NoUserAccountWithThisEmailAddress'))); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
CustomPages::display(CustomPages::LOGGED_OUT); |
|
|
|
|
CustomPages::display(CustomPages::LOST_PASSWORD); |
|
|
|
|
} |
|
|
|
|
CustomPages::display(CustomPages::INDEX_UNLOGGED, array('info' => get_lang('YourPasswordHasBeenEmailed'))); |
|
|
|
|
CustomPages::display( |
|
|
|
|
CustomPages::INDEX_UNLOGGED, |
|
|
|
|
array('info' => get_lang('YourPasswordHasBeenEmailed')) |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$tool_name = get_lang('LostPassword'); |
|
|
|
@ -91,9 +96,9 @@ if (api_get_setting('allow_lostpassword') == 'false') { |
|
|
|
|
api_not_allowed(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (isset($_GET['reset']) && isset($_GET['id'])) { |
|
|
|
|
$message = Display::return_message(Login::reset_password($_GET["reset"], $_GET["id"], true), 'normal', false); |
|
|
|
|
$message .= '<a href="'.api_get_path(WEB_CODE_PATH).'auth/lostPassword.php" class="btn" >'.get_lang('Back').'</a>'; |
|
|
|
|
if (isset($_GET['reset']) && isset($_GET['id'])) { |
|
|
|
|
$message = Display::return_message(Login::reset_password($_GET["reset"], $_GET["id"], true), 'normal', false); |
|
|
|
|
$message .= '<a href="'.api_get_path(WEB_CODE_PATH).'auth/lostPassword.php" class="btn" >'.get_lang('Back').'</a>'; |
|
|
|
|
echo $message; |
|
|
|
|
} else { |
|
|
|
|
$form = new FormValidator('lost_password'); |
|
|
|
@ -107,11 +112,11 @@ if (isset($_GET['reset']) && isset($_GET['id'])) { |
|
|
|
|
|
|
|
|
|
if ($form->validate()) { |
|
|
|
|
$values = $form->exportValues(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$users_related_to_username = Login::get_user_accounts_by_username($values['user']); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($users_related_to_username) { |
|
|
|
|
$by_username = true; |
|
|
|
|
$by_username = true; |
|
|
|
|
foreach ($users_related_to_username as $user) { |
|
|
|
|
if ($_configuration['password_encryption'] != 'none') { |
|
|
|
|
Login::handle_encrypted_password($user, $by_username); |
|
|
|
@ -120,9 +125,9 @@ if (isset($_GET['reset']) && isset($_GET['id'])) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
Display::display_warning_message(get_lang('NoUserAccountWithThisEmailAddress')); |
|
|
|
|
Display::display_warning_message(get_lang('NoUserAccountWithThisEmailAddress')); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
} else { |
|
|
|
|
$form->display(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|