Browse Source

Merge "django22: The 'login' functional-based view is gone (pt. 2)"

tags/16.0.0.0b2
Zuul 1 week ago
parent
commit
1ad86bfa14
1 changed files with 18 additions and 19 deletions
  1. 18
    19
      openstack_auth/views.py

+ 18
- 19
openstack_auth/views.py View File

@@ -53,7 +53,7 @@ LOG = logging.getLogger(__name__)
53 53
 @sensitive_post_parameters()
54 54
 @csrf_protect
55 55
 @never_cache
56
-def login(request, template_name=None, extra_context=None, **kwargs):
56
+def login(request):
57 57
     """Logs a user in using the :class:`~openstack_auth.forms.Login` form."""
58 58
 
59 59
     # If the user enabled websso and the default redirect
@@ -101,27 +101,26 @@ def login(request, template_name=None, extra_context=None, **kwargs):
101 101
     else:
102 102
         form = functional.curry(forms.Login, initial=initial)
103 103
 
104
-    if extra_context is None:
105
-        extra_context = {'redirect_field_name': auth.REDIRECT_FIELD_NAME}
106
-
107
-    extra_context['csrf_failure'] = request.GET.get('csrf_failure')
108
-
109 104
     choices = getattr(settings, 'WEBSSO_CHOICES', ())
110
-    extra_context['show_sso_opts'] = (utils.is_websso_enabled() and
111
-                                      len(choices) > 1)
105
+    extra_context = {
106
+        'redirect_field_name': auth.REDIRECT_FIELD_NAME,
107
+        'csrf_failure': request.GET.get('csrf_failure'),
108
+        'show_sso_opts': utils.is_websso_enabled() and len(choices) > 1,
109
+    }
110
+
111
+    if request.is_ajax():
112
+        template_name = 'auth/_login.html'
113
+        extra_context['hide'] = True
114
+    else:
115
+        template_name = 'auth/login.html'
112 116
 
113
-    if not template_name:
114
-        if request.is_ajax():
115
-            template_name = 'auth/_login.html'
116
-            extra_context['hide'] = True
117
-        else:
118
-            template_name = 'auth/login.html'
117
+    res = django_auth_views.LoginView.as_view(
118
+        template_name=template_name,
119
+        redirect_field_name=auth.REDIRECT_FIELD_NAME,
120
+        form_class=form,
121
+        extra_context=extra_context,
122
+        redirect_authenticated_user=False)(request)
119 123
 
120
-    res = django_auth_views.login(request,
121
-                                  template_name=template_name,
122
-                                  authentication_form=form,
123
-                                  extra_context=extra_context,
124
-                                  **kwargs)
125 124
     # Save the region in the cookie, this is used as the default
126 125
     # selected region next time the Login form loads.
127 126
     if request.method == "POST":

Loading…
Cancel
Save