I am creating a mobile application using React Native powered by Discourse (Communicating via REST Api).
I use the User API Keys flow to make authenticated requests and the MessageBus to listen to different events (Implemented successfully fortunately)
At the moment I am implementing the case where the API Key is revoked, and thus tell the user something similar to “Your session has expired”.
For that I tried to subscribe to /logout/${current_user.id}
(It seems to be what Discourse uses in the frontend), without any success
Is it possible that I should subscribe to another channel or is that kind of information not currently transmitted via MessageBus?
Relevant code:
const messageBus = MessageBus.getInstance();
/* Add the User-Api-Key header to message bus */
messageBus.setToken(currentAccount.apiKey);
messageBus.subscribe(`/logout/${currentAccount.id}`, () => {
console.log(`Logging out account ${currentAccount.username}`);
alert("Your session has expired. Please log in again.");
signOut({ reason: REASON_SESSION_EXPIRED });
/* When Revoken, only delete the account data from the storage */
});
Thanks!