public static function setUserInfoWithJWT($user, $forever = false, $appId = null)
    {
        $userInfo = null;
        if ($user instanceof User) {
            $userInfo = $user->toArray();
            $userInfo['is_sys_admin'] = $user->is_sys_admin;
        }

        if (!empty($userInfo)) {
            $id = array_get($userInfo, 'id');
            $email = array_get($userInfo, 'email');
            $token = JWTUtilities::makeJWTByUser($id, $email, $forever);
            static::setSessionToken($token);

            if (!empty($appId) && !$user->is_sys_admin) {
                static::setSessionData($appId, $id);

                return true;
            } else {
                return static::setUserInfo($userInfo);
            }
        }

        return false;
    }