return {'social_auth': data}
+def social_auth_by_name_backends(request):
+ """Load Social Auth current user data to context.
+ Will add a social_auth object whose attribute names are the names of each
+ provider, e.g. social_auth.facebook would be the facebook association or
+ None, depending on the logged in user's current associations. Providers
+ with a hyphen have the hyphen replaced with an underscore, e.g.
+ google-oauth2 becomes google_oauth2 when referenced in templates.
+ """
+ keys = BACKENDS.keys()
+ accounts = dict(zip(keys, [None] * len(keys)))
+
+ if isinstance(request.user, User) and request.user.is_authenticated():
+ for associated in request.user.social_auth.all():
+ accounts[associated.provider.replace('-', '_')] = associated
+
+ return {'social_auth': accounts}
+
+
def backends_data(user):
"""Return backends data for given user.