Ability to logout via postMessage on ifame integration
Your Rocket.Chat version: 0.40.1
Add ability to logout via postMessage from parent window when Rocket.Chat is integrated via iframe. As of the moment it only accepts 'go' commands.
@tristanflorcb Can you describe in more detail what you're wanting?
RC version: 0.58.2 Iframe integration: sending commands
rcIframe.postMessage({
externalCommand: 'logout'
}, '*');
When I try to log out via iframe commands, my authToken become invalid but I'm still displayed as online in direct chat sidebar - even though browser window is completely closed. What is a proper way of doing logout, should I log out via RestAPI or this is a bug?
Also, with login, I get error message - Error logging in with token: Error: You've been logged out by the server. Please log in again. [403]. (also UI error message "Invalid user"). I've found a workaround with passing both token and loginToken parameters.
rcIframe.postMessage({
externalCommand: 'login-with-token',
loginToken: authToken,
token: authToken
}, '*');
The error still appears but I'm able to login with a valid token.
I see a similar issue. The mentioned API call simply does nothing, the user stays logged in. We are using a custom OAuth provider for RocketChat if that is important.
FYI: I found the solution to my issue. The completely undocumented settings Iframe_Integration_receive_enable and Iframe_Integration_receive_origin must be set to enable sending commands via the iframe:
https://github.com/RocketChat/Rocket.Chat/blob/2.4.11/app/ui/client/lib/iframeCommands.js#L77
I noticed that triggering a logout via externalCommand works but only for new browser tabs which try to access the chat afterwards. Existing tabs keep their sessionStorage and thus their Meteor login token.
It's already working