'Invoked just after a user successfully removed a social account
We use it to reset the name of the socialaccount provider in
the user\'s session to one that he also has.'

def on_social_account_removed(self, sender, request, socialaccount, **kwargs):

    user = socialaccount.user
    try:
        all_socialaccounts = user.socialaccount_set.all()
        next_socialaccount = all_socialaccounts[0]
        request.session['sociallogin_provider'] = next_socialaccount.provider
        request.session.modified = True
    except (ObjectDoesNotExist, IndexError):
        pass
