summaryrefslogtreecommitdiffstats
path: root/hyperkitty/views/accounts.py
diff options
context:
space:
mode:
Diffstat (limited to 'hyperkitty/views/accounts.py')
-rw-r--r--hyperkitty/views/accounts.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/hyperkitty/views/accounts.py b/hyperkitty/views/accounts.py
index 8e5dc03..284eb15 100644
--- a/hyperkitty/views/accounts.py
+++ b/hyperkitty/views/accounts.py
@@ -24,12 +24,14 @@ import logging
from django.conf import settings
from django.core.urlresolvers import reverse
from django.core.exceptions import SuspiciousOperation
-from django.contrib.auth import logout, authenticate, login
+from django.contrib.auth import logout, authenticate, login, get_backends
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User
+from django.contrib.auth.views import login as django_login_view
from django.shortcuts import render, redirect
from django.utils.http import is_safe_url
from django.utils.translation import gettext as _
+from social_auth.backends import SocialAuthBackend
from hyperkitty.models import UserProfile, Rating, Favorite
from hyperkitty.views.forms import RegistrationForm, UserProfileForm
@@ -44,6 +46,20 @@ FLASH_MESSAGES = {
}
+def login_view(request, *args, **kwargs):
+ if "extra_context" not in kwargs:
+ kwargs["extra_context"] = {}
+ if "backends" not in kwargs["extra_context"]:
+ kwargs["extra_context"]["backends"] = []
+ # Note: sorry but I really find the .setdefault() method non-obvious and
+ # harder to re-read that the lines above.
+ for backend in get_backends():
+ if not isinstance(backend, SocialAuthBackend):
+ continue # It should be checked using duck-typing instead
+ kwargs["extra_context"]["backends"].append(backend.name)
+ return django_login_view(request, *args, **kwargs)
+
+
@login_required
def user_profile(request, user_email=None):
if not request.user.is_authenticated():