Tinywan / webman-jwt

🔑 An authentication(认证) library that supports JSON Web Token (JWT) for webman plugin
https://www.workerman.net/plugin/10
Apache License 2.0
50 stars 22 forks source link

Tinywan\Jwt\JwtToken::getUser() 方法返回值 #18

Closed ageChen closed 10 months ago

ageChen commented 10 months ago
/**
 * @desc: 获取当前用户信息
 * @return array
 * @author Tinywan(ShaoBo Wan)
 */
public static function getUser():array
{
    $config = self::_getConfig();
    if (is_callable($config['user_model'])) {
        return $config['user_model'](self::getCurrentId()) ?? [];
    }
    return [];
}

Tinywan\Jwt\JwtToken::getUser() 方法返回值如果定死了array就不能在 配置文件里返回模型对象了

Tinywan commented 10 months ago

你想要返回一个对象?

ageChen commented 10 months ago

文档中不是介绍可以返回数组或对象嘛,其次我是把整个user模型对象放到request对象中,对象方便直接调用属性或方法,这个方法的返回值不局限于array就可以让配置项里的user_model配置更灵活

Tinywan commented 10 months ago

好的,请更新到 v1.8.7