def user_details(strategy, details, user=None, *args, **kwargs):
    """Update user details using data from provider."""
    if user:
        changed = False
        protected = ('username', 'id', 'pk', 'email') + tuple(strategy.
            setting('PROTECTED_USER_FIELDS', []))
        for name, value in details.items():
            if value and hasattr(user, name):
                current_value = getattr(user, name, None)
                if not current_value or name not in protected:
                    changed |= current_value != value
                    setattr(user, name, value)
        if changed:
            strategy.storage.user.changed(user)
