Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Commit

Permalink
activate password reset link, if urls from django-authopenid included
Browse files Browse the repository at this point in the history
  • Loading branch information
jedie committed Jul 31, 2012
1 parent 04d0e32 commit f54da52
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
Expand Up @@ -61,11 +61,8 @@ <h3>Error: For the JS-SHA-Login is Javascript needed!</h3>
</p>
<input id="submit_button" type="submit" value="{% trans 'Log in' %}" />
</form>
{% comment %}
TODO: Reimplement the passwort reset
{% if pass_reset_link %}
{% if pass_reset_link %}{# only available if django-authopenid is installed #}
<a href="{{ pass_reset_link }}">{% trans 'Request a password reset.' %}</a>
{% endif %}
{% endcomment %}
</fieldset>
{% endblock %}
23 changes: 18 additions & 5 deletions pylucid_project/pylucid_plugins/auth/views.py
Expand Up @@ -72,19 +72,19 @@ def login_honeypot(request):
form = HoneypotForm(request.POST)
if form.is_valid():
username = form.cleaned_data["username"]
password = form.cleaned_data["password"]
password = form.cleaned_data["password"]
HonypotAuth.objects.add(request, username, password)
messages.error(request, _("username/password wrong."))
form = HoneypotForm(initial={"username": username})
faked_login_error = True
else:
form = HoneypotForm()
context = {
"form": form,
"form": form,
"form_url": request.path,
"page_robots": "noindex,nofollow",
}

response = render_to_response("auth/login_honeypot.html", context, context_instance=RequestContext(request))
if faked_login_error:
response.status_code = 401
Expand Down Expand Up @@ -299,6 +299,19 @@ def _login_view(request):
# create a new challenge and add it to session
challenge = _get_challenge(request)

try:
# url from django-authopenid, only available if the urls.py are included
reset_link = urlresolvers.reverse("auth_password_reset")
except urlresolvers.NoReverseMatch, err:
try:
# DjangoBB glue plugin adds the urls from django-authopenid
reset_link = PluginPage.objects.reverse("djangobb_plugin", "auth_password_reset")
except urlresolvers.NoReverseMatch, err:
if settings.DEBUG:
reset_link = "#ERROR: %s" % err
else:
reset_link = None

context = {
"challenge": challenge,
"salt_len": crypt.SALT_LEN,
Expand All @@ -307,7 +320,7 @@ def _login_view(request):
"sha_auth_url": request.path + "?auth=sha_auth",
"next_url": next_url,
"form": form,
"pass_reset_link": "#TODO",
"pass_reset_link": reset_link,
}

# IMPORTANT: We must do the following, so that the
Expand All @@ -323,7 +336,7 @@ def _login_view(request):
response = render_to_response('auth/sha_form_debug.html', context, context_instance=RequestContext(request))
else:
response = ajax_response(request, 'auth/sha_form.html', context, context_instance=RequestContext(request))

return response


Expand Down

0 comments on commit f54da52

Please sign in to comment.