Getting user session from jid

Hi there,

we have code like this (inspired by:

module:hook('muc-room-created', function(event)
    local _set_affiliation = room.set_affiliation;
    room.set_affiliation = function(room, actor, jid, affiliation, reason)
        if actor == "token_plugin" then
            return _set_affiliation(room, true, jid, affiliation, reason);
            -- I want to get the session information here
            return _set_affiliation(room, actor, jid, affiliation, reason);

How could we access session object (or origin) for the given jid in the line with the comment -- I want to get the session information here?


To address the above question, we ended up storing the token at login in the store ( and are then retrieving it from the store in the above code and authorize the user before setting the affiliation for him.

For the sake of completeness, we remove the token from the store once the user leaves the room - in the muc-occupant-left event.