#310 Redirect to the password-change-page if the admin has not changed his password yet

This commit is contained in:
Oskar Hahn 2012-07-19 11:43:48 +02:00
parent f928abd006
commit 834c30321b
2 changed files with 11 additions and 10 deletions

View File

@ -41,7 +41,7 @@
$(this).hide("fast"); $(this).hide("fast");
}); });
</script> </script>
<form method="post" action="{% url user_login %}"> <form method="post" action="{% url user_login %}{% if next %}?next={{ next }}{% endif %}">
{% csrf_token %} {% csrf_token %}
<table> <table>
<tr> <tr>

View File

@ -565,21 +565,22 @@ def reset_password(request, user_id):
def login(request): def login(request):
extra_content = {}
try: try:
admin = User.objects.get(pk=1) admin = User.objects.get(pk=1)
if admin.check_password(config['admin_password']): if admin.check_password(config['admin_password']):
first_time_message = _("Installation was successfully! Use %(user)s " extra_content['first_time_essage'] = _(
"(password: %(password)s) for first login.<br>" "Installation was successfully! Use %(user)s "
"<strong>Important:</strong> Please change the password after " "(password: %(password)s) for first login.<br>"
"first login! Otherwise this message still appears for everyone " "<strong>Important:</strong> Please change the password after "
"and could be a security risk.") % { "first login! Otherwise this message still appears for everyone "
"and could be a security risk.") % {
'user': html_strong(admin.username), 'user': html_strong(admin.username),
'password': html_strong(config['admin_password'])} 'password': html_strong(config['admin_password'])}
else: extra_content['next'] = reverse('password_change')
first_time_message = None
except User.DoesNotExist: except User.DoesNotExist:
first_time_message = None pass
return django_login(request, template_name='participant/login.html', extra_context={'first_time_message': first_time_message}) return django_login(request, template_name='participant/login.html', extra_context=extra_content)
def register_tab(request): def register_tab(request):