setID( 'client_contact_password_reset_' . Misc::getRemoteIPAddress() ); $rl->setAllowedCalls( 10 ); $rl->setTimeFrame( 900 ); //15 minutes $validator = new Validator(); //All HTML special chars are encoded prior to getting here, which makes things like "&" be saved as "&", corrupting passwords. $password = FormVariables::reverseSanitize( $password ); $password2 = FormVariables::reverseSanitize( $password2 ); $action = Misc::findSubmitButton(); Debug::Text( 'Action: ' . $action, __FILE__, __LINE__, __METHOD__, 10 ); switch ( $action ) { case 'change_password': Debug::Text( 'Change Password: ' . $key, __FILE__, __LINE__, __METHOD__, 10 ); if ( $rl->check() == false ) { Debug::Text( 'Excessive change password attempts... Preventing resets from: ' . Misc::getRemoteIPAddress() . ' for up to 15 minutes...', __FILE__, __LINE__, __METHOD__, 10 ); sleep( 5 ); //Excessive password attempts, sleep longer. $action = 'reset_password'; } else { $cclf = TTnew( 'ClientContactListFactory' ); /** @var ClientContactListFactory $cclf */ $cclf->getByPasswordResetKey( $key ); if ( $cclf->getRecordCount() == 1 ) { Debug::Text( 'FOUND Password reset key! ', __FILE__, __LINE__, __METHOD__, 10 ); $cc_obj = $cclf->getCurrent(); if ( $cc_obj->checkPasswordResetKey( $key ) == true ) { $user_name = $cc_obj->getUserName(); //Make sure passwords match if ( $password == $password2 ) { //Change password $cc_obj->setPassword( $password ); //Password reset key is cleared when password is changed. if ( $cc_obj->isValid() ) { $cc_obj->Save(); Debug::Text( 'Password Change succesful!', __FILE__, __LINE__, __METHOD__, 10 ); $rl->delete(); //Clear password reset rate limit upon successful reset. //Redirect::Page( URLBuilder::getURL( array('password_reset' => 1 ), 'Login.php' ) ); Redirect::Page( 'https://www.timetrex.com/store?step=login' ); } } else { $validator->isTrue( 'password', false, 'Passwords do not match' ); } } else { Debug::Text( 'DID NOT FIND Valid Password reset key! ', __FILE__, __LINE__, __METHOD__, 10 ); $action = 'reset_password'; } } else { Debug::Text( 'DID NOT FIND Password reset key! ', __FILE__, __LINE__, __METHOD__, 10 ); $action = 'reset_password'; } Debug::text( 'Change Password Failed! Attempt: ' . $rl->getAttempts(), __FILE__, __LINE__, __METHOD__, 10 ); sleep( ( $rl->getAttempts() * 0.5 ) ); //If email is incorrect, sleep for some time to slow down brute force attacks. } break; case 'password_reset': //Debug::setVerbosity( 11 ); Debug::Text( 'Key: ' . $key, __FILE__, __LINE__, __METHOD__, 10 ); if ( $rl->check() == false ) { Debug::Text( 'Excessive reset password attempts... Preventing resets from: ' . Misc::getRemoteIPAddress() . ' for up to 15 minutes...', __FILE__, __LINE__, __METHOD__, 10 ); sleep( 5 ); //Excessive password attempts, sleep longer. $action = 'reset_password'; } else { $cclf = TTnew( 'ClientContactListFactory' ); /** @var ClientContactListFactory $cclf */ $cclf->getByPasswordResetKey( $key ); if ( $cclf->getRecordCount() == 1 ) { Debug::Text( 'FOUND Password reset key! ', __FILE__, __LINE__, __METHOD__, 10 ); $cc_obj = $cclf->getCurrent(); if ( $cc_obj->checkPasswordResetKey( $key ) == true ) { $user_name = $cc_obj->getUserName(); $rl->delete(); //Clear password reset rate limit upon successful reset. } else { Debug::Text( 'DID NOT FIND Valid Password reset key! ', __FILE__, __LINE__, __METHOD__, 10 ); $action = 'reset_password'; } } else { Debug::Text( 'DID NOT FIND Password reset key! ', __FILE__, __LINE__, __METHOD__, 10 ); $action = 'reset_password'; } Debug::text( 'Reset Password Failed! Attempt: ' . $rl->getAttempts(), __FILE__, __LINE__, __METHOD__, 10 ); sleep( ( $rl->getAttempts() * 0.5 ) ); //If email is incorrect, sleep for some time to slow down brute force attacks. } break; case 'reset_password': //Debug::setVerbosity( 11 ); Debug::Text( 'Email: ' . $email, __FILE__, __LINE__, __METHOD__, 10 ); if ( $rl->check() == false ) { Debug::Text( 'Excessive reset password attempts... Preventing resets from: ' . Misc::getRemoteIPAddress() . ' for up to 15 minutes...', __FILE__, __LINE__, __METHOD__, 10 ); sleep( 5 ); //Excessive password attempts, sleep longer. $validator->isTrue( 'email', false, TTi18n::getText( 'Email address was not found in our database (z)' ) ); } else { $cclf = TTnew( 'ClientContactListFactory' ); /** @var ClientContactListFactory $cclf */ //$cclf->getByHomeEmailOrWorkEmail( $email ); $cclf->getByUserName( $email ); if ( $cclf->getRecordCount() == 1 ) { $cc_obj = $cclf->getCurrent(); $cc_obj->sendPasswordResetEmail(); Debug::Text( 'Found USER! ', __FILE__, __LINE__, __METHOD__, 10 ); $rl->delete(); //Clear password reset rate limit upon successful login. Redirect::Page( URLBuilder::getURL( [ 'email_sent' => 1, 'email' => $email ], Environment::getBaseURL() . 'html5/client/ForgotPassword.php' ) ); } else { //Error Debug::Text( 'DID NOT FIND USER! ', __FILE__, __LINE__, __METHOD__, 10 ); $validator->isTrue( 'email', false, 'Email address was not found in our database' ); } Debug::text( 'Reset Password Failed! Attempt: ' . $rl->getAttempts(), __FILE__, __LINE__, __METHOD__, 10 ); sleep( ( $rl->getAttempts() * 0.5 ) ); //If email is incorrect, sleep for some time to slow down brute force attacks. } break; default: break; } $BASE_URL = '../'; $META_TITLE = TTi18n::getText( 'Password Reset' ); require( '../../../includes/Header.inc.php' ); ?>
isValid() ) { ?>

' . $email . ' ' . TTi18n::getText( 'with instructions on how to change your password.' ); ?>
isValid() ) { ?>