コード例 #1
0
    $user_data = LoginWithAmazon_Tools::get_userdata();
    $user_email = $user_data->email;
    $user_id = LoginWithAmazon_Tools::get_customer_id_by_email($user_email);
    $new_account = false;
    if ($user_id) {
        if (!LoginWithAmazon_Tools::is_amazon_user_any($user_id)) {
            // If user exists, but is NOT an Amazon user, then start the merge prompt.
            tep_redirect(LoginWithAmazon_Tools::get_merge_url());
            exit;
        }
    } else {
        $name = explode(' ', $user_data->name, 2);
        $user_id = LoginWithAmazon_Tools::create_user($name[0], $name[1], $user_email);
        $new_account = true;
    }
    LoginWithAmazon_Tools::login_user($user_id);
    if ($new_account) {
        tep_redirect(tep_href_link(FILENAME_CREATE_ACCOUNT_SUCCESS));
        tep_redirect(tep_href_link(FILENAME_DEFAULT));
    } else {
        tep_redirect(tep_href_link(FILENAME_DEFAULT));
    }
}
?>
<html>
    <head>
        <script type="text/javascript">
            function getURLParameter(name, source) {
                return decodeURIComponent((new RegExp('[?|&|#]' + name + '=' +
                    '([^&;]+?)(&|#|;|$)').exec(source)||[,""])[1].replace(/\+/g,'%20'))||
                    null;
コード例 #2
0
 /**
  * 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');
         }
     }
 }