Make WordPress Core

Changeset 8390


Ignore:
Timestamp:
07/21/2008 05:27:27 PM (18 years ago)
Author:
ryan
Message:

Update AtomPub auth to use latest API

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-app.php

    r8374 r8390  
    207207                                // authenticate regardless of the operation and set the current
    208208                                // 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()) {
    212210                                        if ($always_authenticate) {
    213211                                                $this->auth_required('Credentials required.');
     
    10651063         */
    10661064        function authenticate() {
    1067                 $login_data = array();
    1068                 $already_md5 = false;
    1069 
    10701065                log_app("authenticate()",print_r($_ENV, true));
    10711066
     
    10791074                // If Basic Auth is working...
    10801075                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;
    10881082                        }
    10891083                }
    10901084
    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;
    10971086        }
    10981087
Note: See TracChangeset for help on using the changeset viewer.