Changeset 8390
- Timestamp:
- 07/21/2008 05:27:27 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-app.php
r8374 r8390 207 207 // authenticate regardless of the operation and set the current 208 208 // user. each handler will decide if auth is required or not. 209 $this->authenticate(); 210 $u = wp_get_current_user(); 211 if(!isset($u) || $u->ID == 0) { 209 if(!$this->authenticate()) { 212 210 if ($always_authenticate) { 213 211 $this->auth_required('Credentials required.'); … … 1065 1063 */ 1066 1064 function authenticate() { 1067 $login_data = array();1068 $already_md5 = false;1069 1070 1065 log_app("authenticate()",print_r($_ENV, true)); 1071 1066 … … 1079 1074 // If Basic Auth is working... 1080 1075 if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) { 1081 $login_data = array('login' => $_SERVER['PHP_AUTH_USER'], 'password' => $_SERVER['PHP_AUTH_PW']); 1082 log_app("Basic Auth",$login_data['login']); 1083 } else { 1084 // else, do cookie-based authentication 1085 if (function_exists('wp_get_cookie_login')) { 1086 $login_data = wp_get_cookie_login(); 1087 $already_md5 = true; 1076 log_app("Basic Auth",$_SERVER['PHP_AUTH_USER']); 1077 $user = wp_authenticate($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); 1078 if ( $user && !is_wp_error($user) ) { 1079 wp_set_current_user($user->ID); 1080 log_app("authenticate()", $_SERVER['PHP_AUTH_USER']); 1081 return true; 1088 1082 } 1089 1083 } 1090 1084 1091 // call wp_login and set current user 1092 if (!empty($login_data) && wp_login($login_data['login'], $login_data['password'], $already_md5)) { 1093 $current_user = new WP_User(0, $login_data['login']); 1094 wp_set_current_user($current_user->ID); 1095 log_app("authenticate()",$login_data['login']); 1096 } 1085 return false; 1097 1086 } 1098 1087
Note: See TracChangeset
for help on using the changeset viewer.