forked from rodrigoprimo/social-connect
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f72d6a1
commit 6874f19
Showing
6 changed files
with
155 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,45 @@ | ||
<?php | ||
|
||
require_once(dirname(dirname(__FILE__)) . '/openid/openid.php'); | ||
require_once(dirname(dirname(__FILE__)) . '/utils.php' ); | ||
|
||
try { | ||
if(!isset($_GET['openid_mode']) || $_GET['openid_mode'] == 'cancel') { | ||
$openid = new LightOpenID; | ||
$openid->identity = 'https://www.google.com/accounts/o8/id'; | ||
$openid->required = array('namePerson/first', 'namePerson/last', 'contact/email'); | ||
header('Location: ' . $openid->authUrl()); | ||
} else { | ||
$openid = new LightOpenID; | ||
if($openid->validate()) { | ||
$google_id = $openid->identity; | ||
$attributes = $openid->getAttributes(); | ||
$email = $attributes['contact/email']; | ||
$first_name = $attributes['namePerson/first']; | ||
$last_name = $attributes['namePerson/last']; | ||
$signature = social_connect_generate_signature($google_id); | ||
do_action( 'social_connect_before_register_google', $google_id, $signature ); | ||
?> | ||
<html> | ||
<head> | ||
<script> | ||
function init() { | ||
window.opener.wp_social_connect({'action' : 'social_connect', 'social_connect_provider' : 'google', | ||
'social_connect_openid_identity' : '<?php echo $google_id ?>', | ||
'social_connect_signature' : '<?php echo $signature ?>', | ||
'social_connect_email' : '<?php echo $email ?>', | ||
'social_connect_first_name' : '<?php echo $first_name ?>', | ||
'social_connect_last_name' : '<?php echo $last_name ?>'}); | ||
|
||
window.close(); | ||
} | ||
</script> | ||
</head> | ||
<body onload="init();"> | ||
</body> | ||
</html> | ||
<?php | ||
} | ||
} | ||
if (!isset($_GET['openid_mode']) || $_GET['openid_mode'] == 'cancel') { | ||
$openid = new LightOpenID; | ||
$openid->identity = 'https://www.google.com/accounts/o8/id'; | ||
$openid->required = array('namePerson/first', 'namePerson/last', 'contact/email'); | ||
header('Location: ' . $openid->authUrl()); | ||
} else { | ||
$openid = new LightOpenID; | ||
if ($openid->validate()) { | ||
$google_id = $openid->identity; | ||
$attributes = $openid->getAttributes(); | ||
$email = $attributes['contact/email']; | ||
$first_name = $attributes['namePerson/first']; | ||
$last_name = $attributes['namePerson/last']; | ||
$signature = social_connect_generate_signature($google_id); | ||
do_action( 'social_connect_before_register_google', $google_id, $signature ); | ||
?> | ||
<html> | ||
<head> | ||
<script> | ||
function init() { | ||
window.opener.wp_social_connect({'action' : 'social_connect', 'social_connect_provider' : 'google', | ||
'social_connect_openid_identity' : '<?php echo $google_id ?>', | ||
'social_connect_signature' : '<?php echo $signature ?>', | ||
'social_connect_email' : '<?php echo $email ?>', | ||
'social_connect_first_name' : '<?php echo $first_name ?>', | ||
'social_connect_last_name' : '<?php echo $last_name ?>'}); | ||
|
||
window.close(); | ||
} | ||
</script> | ||
</head> | ||
<body onload="init();"></body> | ||
</html> | ||
<?php | ||
} | ||
} | ||
} catch(ErrorException $e) { | ||
echo $e->getMessage(); | ||
echo $e->getMessage(); | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,61 @@ | ||
<?php | ||
|
||
require_once(dirname(dirname(__FILE__)) . '/openid/openid.php'); | ||
require_once(dirname(dirname(__FILE__)) . '/utils.php' ); | ||
|
||
try { | ||
if(!isset($_GET['openid_mode'])) { | ||
if (!isset($_GET['openid_mode'])) { | ||
$openid = new LightOpenID; | ||
$openid->identity = urldecode($_GET['wordpress_blog_url']); | ||
$openid->required = array('namePerson', 'namePerson/friendly', 'contact/email'); | ||
header('Location: ' . $openid->authUrl()); | ||
} elseif($_GET['openid_mode'] == 'cancel') { | ||
?> | ||
<html> | ||
?> | ||
<html> | ||
<body> | ||
<p><?php _e( 'You have cancelled this login. Please close this window and try again.', 'social-connect' ); ?></p> | ||
</body> | ||
</html> | ||
<?php | ||
</html> | ||
<?php | ||
} else { | ||
$openid = new LightOpenID; | ||
if($openid->validate()) { | ||
if ($openid->validate()) { | ||
$wordpress_id = $openid->identity; | ||
$attributes = $openid->getAttributes(); | ||
$email = isset($attributes['contact/email']) ? $attributes['contact/email'] : ''; | ||
$name = isset($attributes['namePerson']) ? $attributes['namePerson'] : ''; | ||
$signature = social_connect_generate_signature($wordpress_id); | ||
if($email == '') { | ||
if ($email == '') { | ||
?> | ||
<html> | ||
<body> | ||
<p><?php _e( 'You need to share your email address when prompted at wordpress.com. Please close this window and try again.', 'social-connect' ); ?></p> | ||
</body> | ||
<body> | ||
<p><?php _e( 'You need to share your email address when prompted at wordpress.com. Please close this window and try again.', 'social-connect' ); ?></p> | ||
</body> | ||
</html> | ||
<?php | ||
die(); | ||
die(); | ||
} | ||
do_action( 'social_connect_before_register_wordpress', $wordpress_id, $signature ); | ||
?> | ||
<html> | ||
<head> | ||
<script> | ||
function init() { | ||
window.opener.wp_social_connect({'action' : 'social_connect', 'social_connect_provider' : 'wordpress', | ||
'social_connect_signature' : '<?php echo $signature ?>', | ||
'social_connect_openid_identity' : '<?php echo $wordpress_id ?>', | ||
'social_connect_email' : '<?php echo $email ?>', | ||
'social_connect_name' : '<?php echo $name ?>' | ||
}); | ||
window.close(); | ||
?> | ||
<html> | ||
<head> | ||
<script> | ||
function init() { | ||
window.opener.wp_social_connect({'action' : 'social_connect', 'social_connect_provider' : 'wordpress', | ||
'social_connect_signature' : '<?php echo $signature ?>', | ||
'social_connect_openid_identity' : '<?php echo $wordpress_id ?>', | ||
'social_connect_email' : '<?php echo $email ?>', | ||
'social_connect_name' : '<?php echo $name ?>' | ||
}); | ||
window.close(); | ||
} | ||
</script> | ||
</head> | ||
<body onload="init();"></body> | ||
</html> | ||
<?php | ||
} | ||
} | ||
</script> | ||
</head> | ||
<body onload="init();"> | ||
</body> | ||
</html> | ||
<?php | ||
} | ||
} | ||
} catch(ErrorException $e) { | ||
echo $e->getMessage(); | ||
} | ||
?> |
Oops, something went wrong.