Links

clean-logout.s

Owner: Louis Lagrange

Checks

You should remove all persisted and in-memory user content after a logout. You should logout from every external services silently.
  • If my project uses react-apollo
  • If my project uses redux
    • there is a LOGOUT or RESET_CUSTOMER_DATA action that replaces the user reducers' states with the initial states
  • If my project uses React-Native AsyncStorage
  • Errors should be caught and handled

Good examples

// pseudo code
const logout = async () => {
try {
await fetch('ZENDESK_LOGOUT_URL', { method: 'GET' });
await firebase.auth().signOut();
await AsyncStorage.clear();
ReduxStore.dispatch(resetCustomerData());
apolloClient.resetStore();
Navigation.navigate('login');
} catch (e) {
HandleErrorService.handleError(e);
// eventually show an error or retry
}
}

Bad examples

Example 1

Without cleaning the user data, you will have state and data inconsistencies with the new user.
// pseudo code
const logout = async () => {
Navigation.navigate('login');
}

Example 2

Without the try catch, the app will crash if the user has no connection, or if another error happens.
// pseudo code
const logout = async () => {
await fetch('ZENDESK_LOGOUT_URL', { method: 'GET' });
await firebase.auth().signOut();
await AsyncStorage.clear();
ReduxStore.dispatch(resetCustomerData());
apolloClient.resetStore();
Navigation.navigate('login');
}