HEX
Server: Apache/2.4.59 (Debian)
System: Linux keymana 4.19.0-21-cloud-amd64 #1 SMP Debian 4.19.249-2 (2022-06-30) x86_64
User: lijunjie (1003)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/dk/wp-content/themes/food/api/user/r_user_login.php
<?php
/**
 * 用户登陆
 * @param $userObj
 * @return stdClass
 */

$userObj = new stdClass();
$userObj->email = CheckFunc::checkInput2('email', 50);
$userObj->pwd = CheckFunc::checkInput2('pwd', 50);

$resObj = loginFunc($userObj);

$rc = $resObj->rc;
$rv->msg = $resObj->msg;

/**
 * 用户登陆
 * @param $userObj
 * @return stdClass
 */
function loginFunc($userObj)
{
//    print_r($userObj);
    $resInfo = new stdClass();

    $user_email = $userObj->email;
    $user_pass = $userObj->pwd;

    $resInfo->rc = ApiErrorDesc::ERR_PARAMS[0];
    $resInfo->msg = ApiErrorDesc::ERR_PARAMS[1];

    if($user_email == '' || $user_pass == ''){
        return $resInfo;
    }

    $user = wp_signon(array('user_login' => $user_email, 'user_password' => $user_pass, 'remember' => true), false);
//    $user = wp_signon( $creds, false );

//    if (is_wp_error($user)) {
//        echo $user->get_error_message();
//    }

//    print_r($user);

    if (is_wp_error($user)) {
//        echo $user->get_error_message();
        $resInfo->rc = ApiErrorDesc::ERR_DONE[0];
        $resInfo->msg = $user->get_error_message();

        //密码错误
        if(strpos($user->get_error_message(), 'The password you entered for the username') !== false ){
            $resInfo->rc = ApiErrorDesc::ERR_LOGIN_PASSWORD[0];
            $resInfo->msg = ApiErrorDesc::ERR_LOGIN_PASSWORD[1];
        }

        //字符串包含 is not registered on
        //账号不存在
        if(strpos($user->get_error_message(), 'is not registered on') !== false){
            $resInfo->rc = ApiErrorDesc::ERR_LOGIN_USER[0];
            $resInfo->msg = ApiErrorDesc::ERR_LOGIN_USER[1];
        }
    } else {
        $resInfo->rc = ApiErrorDesc::SUCCESS[0];
        $resInfo->msg = ApiErrorDesc::SUCCESS[1];
    }

    return $resInfo;
}