Fix Call to a member function getPreferences() on a non-object when not logged in