関数
LoginWithAmazon::loginWithAmazonSignIn()
説明 説明
This method will return an error if the user has the Amazon login feature turned off on マイページ
ファイル: src/API/LoginWithAmazon.php
public function loginWithAmazonSignIn() {
global $wpdb;
$token = isset($_GET['buyerToken']) ? $_GET['buyerToken'] : '';
if (empty($token)) {
return __('Oops! An unknown error occured.', 'wcexaap');
}
$result = (new GetBuyer($this->module))->get($token);
if ($result instanceof GenericError) {
return $result->message;
}
if (empty($result)) {
return __('Oops! An unknown error occured.', 'wcexaap');
}
$buyerInfo = json_decode($result['response'], true);
$email = $buyerInfo['email'];
$member_table = $wpdb->prefix . 'usces_member';
$query = $wpdb->prepare("SELECT ID FROM $member_table WHERE mem_email = %s", $email);
$id = $wpdb->get_var($query);
if (!$id) {
return __('<b>Error:</b> E-mail address is not correct.', 'usces');
}
$mmeta = new MemberMeta((int)$id);
if ($mmeta->getAllowAmazonToWelcartLogin() === false) {
return __('Cannot login to this account with Amazon.', 'wcexaap');
}
$this->executeLogin($email);
/**
* Mirrored Welcart action hook
*
* @ignore
*/
do_action('usces_action_after_login');
}