Permalink
Browse files

Merge pull request #924 from ojii/issue-897

Fixed #897 by only accessing request.POST in the middleware when we're pr
  • Loading branch information...
2 parents a040642 + 932f7ec commit 759ddbf6ddf68ccb7ce9bba706a440fb68505191 @chrisglass chrisglass committed Aug 4, 2011
Showing with 10 additions and 9 deletions.
  1. +9 −8 cms/cms_toolbar.py
  2. +1 −1 cms/templates/cms/toolbar/items/login.html
View
17 cms/cms_toolbar.py
@@ -219,11 +219,12 @@ def _request_hook_get(self):
def _request_hook_post(self):
# login hook
- login_form = CMSToolbarLoginForm(self.request.POST)
- if login_form.is_valid():
- username = login_form.cleaned_data['cms_username']
- password = login_form.cleaned_data['cms_password']
- user = authenticate(username=username, password=password)
- if user:
- login(self.request, user)
- self.init()
+ if 'cms-toolbar-login' in self.request.GET:
+ login_form = CMSToolbarLoginForm(self.request.POST)
+ if login_form.is_valid():
+ username = login_form.cleaned_data['cms_username']
+ password = login_form.cleaned_data['cms_password']
+ user = authenticate(username=username, password=password)
+ if user:
+ login(self.request, user)
+ self.init()
View
2 cms/templates/cms/toolbar/items/login.html
@@ -1,5 +1,5 @@
{% load i18n %}
-<form action="." method="post" id="cms_toolbar-item_login" class="cms_toolbar-item{% if auth_error %} cms_toolbar_error{% endif %}">
+<form action="?cms-toolbar-login=1" method="post" id="cms_toolbar-item_login" class="cms_toolbar-item{% if auth_error %} cms_toolbar_error{% endif %}">
<fieldset>
{% csrf_token %}
<label for="cms_toolbar-item_login-username">{% trans "Username" %}</label>

0 comments on commit 759ddbf

Please sign in to comment.