fix #9

parent ccfe9b9d
......@@ -40,7 +40,7 @@
<div class="col-md-6">
<div class="ibox-content">
<div><img src="{% static 'img/logo.png' %}" width="82" height="82"> <span class="font-bold text-center" style="font-size: 32px; font-family: inherit">{% trans 'Login' %}</span></div>
<form class="m-t" role="form" method="post" action="{% url 'users:login' %}">
<form class="m-t" role="form" method="post" action="">
{% csrf_token %}
{% if form.errors %}
{% if 'captcha' in form.errors %}
......
......@@ -41,12 +41,17 @@ class UserLoginView(FormView):
def get(self, request, *args, **kwargs):
if request.user.is_staff:
return redirect(request.POST.get(self.redirect_field_name, reverse('index')))
return self.render_to_response(self.get_context_data(**kwargs))
return redirect(self.get_success_url())
return super(UserLoginView, self).get(request, *args, **kwargs)
def form_valid(self, form):
auth_login(self.request, form.get_user())
return redirect(self.request.POST.get(self.redirect_field_name, reverse('index')))
return redirect(self.get_success_url())
def get_success_url(self):
return self.request.POST.get(
self.redirect_field_name,
self.request.GET.get(self.redirect_field_name, reverse('index')))
@method_decorator(never_cache, name='dispatch')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment