Angular factory, how to completely change result

I am currently working on Angular and bump into an issue with factories and user login/logout.

Here is an example showing a use case :

An angular application supports user login and logout, as long as user is logged in, it is required the user's messages are loaded inside a MessageList (which is a factory). At first though, I set up an event system to trigger load/reset user messages if the user login or logout from the application. Here is the factory in code :