/** * If a native user tries log in with Amazon, prompt them to merge the accounts. * * @return bool */ private function renderMergePost() { $user_data = LoginWithAmazon_Tools::get_userdata(); $email = $user_data->email; $password = isset($_POST['password']) ? $_POST['password'] : NULL; if (empty($email)) { return TRUE; } $cust_id = LoginWithAmazon_Tools::get_customer_id_by_email($email); if (!$cust_id) { return TRUE; } $password_hash = LoginWithAmazon_Tools::get_customer_password_hash_by_id($cust_id); if (!LoginWithAmazon_Tools::is_amazon_user_any($cust_id)) { global $messageStack; $authenticated = tep_validate_password($password, $password_hash); if ($authenticated) { LoginWithAmazon_Tools::add_user_to_merge_table($cust_id); LoginWithAmazon_Tools::login_user($cust_id); tep_redirect(tep_href_link(FILENAME_ACCOUNT, LoginWithAmazon_Tools::MERGE_ACCOUNTS_SUCCESS . '=1')); } else { // Set an error message $messageStack->add('login', MODULE_HEADER_TAGS_LOGINWITHAMAZON_MERGE_FAIL, 'error'); } } }