Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

Ability to logout via postMessage on ifame integration

Open tristanflorcb opened this issue 10 years ago • 6 comments

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 avatar Sep 23 '16 06:09 tristanflorcb

@tristanflorcb Can you describe in more detail what you're wanting?

graywolf336 avatar Feb 03 '17 13:02 graywolf336

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.

bsubasic avatar Oct 11 '17 16:10 bsubasic

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.

mbrodala avatar Oct 10 '19 14:10 mbrodala

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

mbrodala avatar Mar 23 '20 10:03 mbrodala

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.

mbrodala avatar Apr 16 '20 09:04 mbrodala

It's already working

hugocostadev avatar Mar 30 '23 18:03 hugocostadev