. // ADD COMMENT require_once("../inc/util.inc"); require_once("../inc/token.inc"); require_once("../inc/email.inc"); require_once("../inc/password_compat/password.inc"); check_get_args(array("id", "token")); redirect_to_secure_url("recover_email.php"); $user = get_logged_in_user(false); //Log out to clear all auth tokens if ($user) { clear_cookie('auth'); $g_logged_in_user = null; } page_head(tra("Recover email address")); $userid = get_int("id", true); $token = get_str("token", true); if (is_valid_token($userid, $token, TOKEN_TYPE_CHANGE_EMAIL)) { $tmpuser = BoincUser::lookup_id_nocache($userid); // We can only change passwd_hash if we can get the userdata. // if ($tmpuser) { $existing = BoincUser::lookup_email_addr($tmpuser->previous_email_addr); if ($existing) { echo tra("There is already an account with that email address.")."

".tra("Please contact the admin. Previous email address could not be reverted as another account is using it as their email address."); } else { echo tra("Email address has been reverted.")."

".tra("You need to reset your password: ")."".secure_url_base()."get_passwd.php"; $database_passwd_hash = password_hash(random_string() , PASSWORD_DEFAULT); //Change previous_email $result = $tmpuser->update( "email_addr=previous_email_addr, previous_email_addr=null, email_addr_change_time=0, passwd_hash='$database_passwd_hash', email_validated=0" ); $result = delete_token($userid, $token, TOKEN_TYPE_CHANGE_EMAIL); } } else { echo tra("Invalid token."); } } else { echo tra("Invalid token."); } page_tail(); ?>