deepstreamIO / deepstream.io

deepstream.io server
https://deepstreamio.github.io
MIT License
7.14k stars 381 forks source link

socketWrapper.serverData in canPerformAction is empty #1059

Closed caracal7 closed 4 years ago

caracal7 commented 4 years ago

Deepstream 5.0.12


const { DeepstreamPlugin } = require('@deepstream/types');

module.exports = class Permission extends DeepstreamPlugin {

    constructor ( pluginOptions,  services) {
        super( pluginOptions,  services);
    }

    async canPerformAction (socketWrapper, message, callback, passItOn) {
        console.log('canPerformAction',
            socketWrapper.userId,
            socketWrapper.isRemote,
            socketWrapper.serverData, // <---------- Empty
            socketWrapper.clientData, // <---------- Empty
            message.topic,
            message.action
         );

     return callback(socketWrapper, message, passItOn, null, true);
    }

    async whenReady () {}

    close () {}
}

authentication

const isValidUser = async ( handshakeData, authData ) => {
       ///........
    return {
        isValid: true,
        id: username,
        clientData: { msgFromAuthServer: `I am ${username} and i logged in` },
        serverData: { group },
    }
}
yasserf commented 4 years ago

That should work. Can you specific your server version?

caracal7 commented 4 years ago

Sorry. Its seems like my mistake. I don't know what I did but everything works as expected