Changeset 872768
- Timestamp:
- 03/10/2014 02:26:15 PM (10 years ago)
- Location:
- wp-restful-single-sign-on
- Files:
-
- 11 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
wp-restful-single-sign-on/trunk/RestfulSingleSignOn/HttpResponse.php
r836382 r872768 229 229 { 230 230 $resp = null; 231 if (!empty($wp_response) ) {231 if (!empty($wp_response)) { 232 232 $body = isset($wp_response['body']) ? $wp_response['body'] : ''; 233 233 $resp = new RestfulSingleSignOn_HttpResponse($body); -
wp-restful-single-sign-on/trunk/RestfulSingleSignOnPlugin.php
r836382 r872768 209 209 if (!empty($email_property) && !empty($current_user_endpoint)) { 210 210 $resp = $this->_getAuthInterface()->getCurrentUserInfo($_COOKIE[$auth_cookie_name]); 211 $data = $resp->getParsedBody(); 212 if ( 213 (!$data instanceof WP_Error) 214 && !empty($data[$email_property]) 215 ) { 216 $found_user = get_user_by('email', $data[$email_property]); 217 if (!empty($found_user->ID)) { 218 $current_user = $found_user; 219 wp_set_current_user($found_user->ID); 211 if (!is_null($resp)) { 212 $data = $resp->getParsedBody(); 213 if ( 214 (!$data instanceof WP_Error) 215 && !empty($data[$email_property]) 216 ) { 217 $found_user = get_user_by('email', $data[$email_property]); 218 if (!empty($found_user->ID)) { 219 $current_user = $found_user; 220 wp_set_current_user($found_user->ID); 221 } 220 222 } 221 223 } … … 440 442 if ($db_user->get('restful_sso_user')) { 441 443 $resp = $this->_getAuthInterface()->authenticateUser($username, $password); 444 445 446 447 448 449 450 451 452 453 454 455 456 457 442 458 $data = $resp->getParsedBody(); 443 459 if (!$data instanceof WP_Error) { 444 $user = $db_user; 460 // Let's create a user in the WordPress system corresponding to the user. 461 $arbitrary_password = sha1(uniqid(microtime())); 462 $user_id = wp_create_user($username, $arbitrary_password, $data[$email_property]); 463 update_user_meta($user_id, 'first_name', $data[$first_name_property]); 464 update_user_meta($user_id, 'last_name', $data[$last_name_property]); 465 update_user_meta($user_id, 'restful_sso_user', true); 466 467 $user = get_user_by('id', $user_id); 445 468 if (0 < count($cookies_to_set)) { 446 469 $this->_set_cookies_from_response($cookies_to_set, $cookie_domain, $resp); 447 470 } 448 }449 }450 451 } else {452 $resp = $this->_getAuthInterface()->authenticateUser($username, $password);453 $data = $resp->getParsedBody();454 if (!$data instanceof WP_Error) {455 // Let's create a user in the WordPress system corresponding to the user.456 $arbitrary_password = sha1(uniqid(microtime()));457 $user_id = wp_create_user($username, $arbitrary_password, $data[$email_property]);458 update_user_meta($user_id, 'first_name', $data[$first_name_property]);459 update_user_meta($user_id, 'last_name', $data[$last_name_property]);460 update_user_meta($user_id, 'restful_sso_user', true);461 462 $user = get_user_by('id', $user_id);463 if (0 < count($cookies_to_set)) {464 $this->_set_cookies_from_response($cookies_to_set, $cookie_domain, $resp);465 471 } 466 472 } … … 496 502 $username = $user->user_email; 497 503 $resp = $this->_getAuthInterface()->requestPasswordReset($username); 498 $result = $resp->getParsedBody(); 499 if ($result instanceof WP_Error) { 500 $phpmailer = new RestfulSingleSignOn_DummyMailer(false, $result); 501 } else { 502 $phpmailer = new RestfulSingleSignOn_DummyMailer(false, true); 504 if (!is_null($resp)) { 505 $result = $resp->getParsedBody(); 506 if ($result instanceof WP_Error) { 507 $phpmailer = new RestfulSingleSignOn_DummyMailer(false, $result); 508 } else { 509 $phpmailer = new RestfulSingleSignOn_DummyMailer(false, true); 510 } 503 511 } 504 512 } -
wp-restful-single-sign-on/trunk/readme.txt
r836382 r872768 5 5 Requires at least: 3.8 6 6 Tested up to: 3.8 7 Stable tag: 1.0. 17 Stable tag: 1.0. 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 56 56 == Changelog == 57 57 58 59 60 58 61 = 1.0 = 59 62 Initial release of plugin
Note: See TracChangeset
for help on using the changeset viewer.