Refactore get_preferences for login and user preferences

issue3514
review1831002