#306 show admin password if it hasn't changed
This commit is contained in:
parent
68b7a22375
commit
b327d41ee6
@ -173,13 +173,15 @@ def create_or_reset_admin_user():
|
|||||||
# can't be imported in global scope as it already requires
|
# can't be imported in global scope as it already requires
|
||||||
# the settings module during import
|
# the settings module during import
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
from openslides.config.models import config
|
||||||
try:
|
try:
|
||||||
obj = User.objects.get(username = "admin")
|
obj = User.objects.get(username = "admin")
|
||||||
except User.DoesNotExist:
|
except User.DoesNotExist:
|
||||||
User.objects.create_superuser(
|
User.objects.create_superuser(
|
||||||
username = "admin",
|
username="admin",
|
||||||
password = "admin",
|
password="admin",
|
||||||
email = "admin@example.com")
|
email="admin@example.com")
|
||||||
|
config['admin_password'] = "admin"
|
||||||
print("Created default admin user")
|
print("Created default admin user")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -27,12 +27,20 @@
|
|||||||
<em>{% trans "Your username and password were not accepted. Please try again." %}</em>
|
<em>{% trans "Your username and password were not accepted. Please try again." %}</em>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<script>
|
|
||||||
$("div.notification").click(function () {
|
|
||||||
$(this).hide("fast");
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if first_time_message %}
|
||||||
|
<div class="notification info">
|
||||||
|
<a class="close" href="#">
|
||||||
|
<img alt="close" title="{% trans 'Close this notification' %}" src="{% static 'images/icons/cross.png' %}">
|
||||||
|
</a>
|
||||||
|
<em>{{ first_time_message|safe }}</em>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<script>
|
||||||
|
$("div.notification").click(function () {
|
||||||
|
$(this).hide("fast");
|
||||||
|
});
|
||||||
|
</script>
|
||||||
<form method="post" action="{% url user_login %}">
|
<form method="post" action="{% url user_login %}">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<table>
|
<table>
|
||||||
|
@ -31,6 +31,7 @@ from django.contrib import messages
|
|||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.contrib.auth.models import User, Group
|
from django.contrib.auth.models import User, Group
|
||||||
from django.contrib.auth.forms import PasswordChangeForm
|
from django.contrib.auth.forms import PasswordChangeForm
|
||||||
|
from django.contrib.auth.views import login as django_login
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
from django.utils.translation import ugettext as _, ungettext
|
from django.utils.translation import ugettext as _, ungettext
|
||||||
@ -40,7 +41,7 @@ from openslides.utils.pdf import stylesheet
|
|||||||
from openslides.utils.template import Tab
|
from openslides.utils.template import Tab
|
||||||
from openslides.utils.utils import (template, permission_required,
|
from openslides.utils.utils import (template, permission_required,
|
||||||
gen_confirm_form, ajax_request, decodedict, encodedict,
|
gen_confirm_form, ajax_request, decodedict, encodedict,
|
||||||
delete_default_permissions)
|
delete_default_permissions, html_strong)
|
||||||
from openslides.utils.views import FormView, PDFView
|
from openslides.utils.views import FormView, PDFView
|
||||||
|
|
||||||
from openslides.config.models import config
|
from openslides.config.models import config
|
||||||
@ -563,6 +564,21 @@ def reset_password(request, user_id):
|
|||||||
return redirect(reverse('user_edit', args=[user_id]))
|
return redirect(reverse('user_edit', args=[user_id]))
|
||||||
|
|
||||||
|
|
||||||
|
def login(request):
|
||||||
|
try:
|
||||||
|
admin = User.objects.get(pk=1)
|
||||||
|
if admin.check_password(config['admin_password']):
|
||||||
|
first_time_message = _("The password for the user %(user)s is "
|
||||||
|
"%(password)s. Please change it") % {
|
||||||
|
'user': html_strong(admin.username),
|
||||||
|
'password': html_strong(config['admin_password'])}
|
||||||
|
else:
|
||||||
|
first_time_message = None
|
||||||
|
except User.DoesNotExist:
|
||||||
|
first_time_message = None
|
||||||
|
return django_login(request, template_name='participant/login.html', extra_context={'first_time_message': first_time_message})
|
||||||
|
|
||||||
|
|
||||||
def register_tab(request):
|
def register_tab(request):
|
||||||
"""
|
"""
|
||||||
Register the participant tab.
|
Register the participant tab.
|
||||||
|
@ -16,9 +16,9 @@ from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
|||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
from django.utils.importlib import import_module
|
from django.utils.importlib import import_module
|
||||||
|
|
||||||
|
|
||||||
from openslides.utils.views import FrontPage
|
from openslides.utils.views import FrontPage
|
||||||
|
|
||||||
|
|
||||||
handler500 = 'openslides.utils.views.server_error'
|
handler500 = 'openslides.utils.views.server_error'
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
@ -59,8 +59,7 @@ urlpatterns += patterns('',
|
|||||||
(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict),
|
(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict),
|
||||||
|
|
||||||
url(r'^login/$',
|
url(r'^login/$',
|
||||||
'django.contrib.auth.views.login',
|
'openslides.participant.views.login',
|
||||||
{'template_name': 'participant/login.html'},
|
|
||||||
name='user_login',
|
name='user_login',
|
||||||
),
|
),
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user