Realm js - How to hide previous user account data when logout

108 views Asked by At

I'm facing an issue with realm.js. I add an object and give permission to that, and it seems to work well, but when I log out and then log in with another account I can see the previous data on device (even the ones for those I don't have permissions, that I can only read but not edit).

So now, I don't have permissions to read or query those data but I'm able to receive live updates (not as expected) and see them! How can I prevent that to happens?

Thank you

1

There are 1 answers

1
Jaydeep Patel On

I think you need to clear your redux store as defined below.

const { Types, Creators } = createActions({
  desktopSuccess: ['payload'],
  desktopClear: [],
});

export const desktopReducer = createReducer(INITIAL_STATE, {
  [Types.DESKTOP_SUCCESS]: success,
  [Types.DESKTOP_CLEAR]: clear,
});

On click of logout clear your store as shown under:

onPressLogOut = () => {
    AsyncStorage.clear();
    store.dispatch(DesktopAction.desktopClear());
    this.props.navigation.navigate('LoginScreen');
  };