From a3f00bfc357b07d67f42a4234fa491623b004689 Mon Sep 17 00:00:00 2001 From: Johan Lundberg Date: Wed, 25 May 2011 11:34:30 +0200 Subject: Added *args to change_other. Changed default lenght of reset password to 10. --- templates/changepw/change_other.html | 2 +- urls.py | 1 + views.py | 18 +++++++++++------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/templates/changepw/change_other.html b/templates/changepw/change_other.html index c3fa637..2131ea4 100644 --- a/templates/changepw/change_other.html +++ b/templates/changepw/change_other.html @@ -11,7 +11,7 @@ Input: - + diff --git a/urls.py b/urls.py index 8ac6782..2674519 100644 --- a/urls.py +++ b/urls.py @@ -6,4 +6,5 @@ urlpatterns = patterns('apps.changepw.views', url(r'^/changepw$', 'change_password', name='changepw'), url(r'^/resetpw$', 'reset_password', name='resetpw'), url(r'^/changeother$', 'change_other', name='changeother'), + url(r'^/[-\w]+$', 'change_other'), ) diff --git a/views.py b/views.py index fd2c0ce..5ea1b3f 100644 --- a/views.py +++ b/views.py @@ -1,4 +1,5 @@ from django.contrib.auth.decorators import login_required +from django.http import Http404 from apps.changepw.models import ChangePasswordForm from django.shortcuts import render_to_response from django.template import RequestContext @@ -18,13 +19,16 @@ def _reset_password(request, user, new_password): # ret = your_pw_change_module.reset_password(user, new_password) return 0 -def _change_other(request): +def _change_other(request, *args): ''' Use this to call your change function. ''' - # user = request.user - # ssh_key = request.POST.getattr('ssh_key') - # ret = your_ldap_module.change_public_ssh_key(user, ssh_key) + #if arg in args: + # user = request.user + # ssh_key = request.POST.getattr('ssh_key') + # ret = your_ldap_module.change_public_ssh_key(user, ssh_key) + #else: + # raise Http404 return 0 def _get_username(request): @@ -85,7 +89,7 @@ def reset_password(request): Resets password for the authenticated user to a random string. The function that actually sets the new password has to be provided as func. ''' - password_length = 8 # chars + password_length = 10 # chars username = _get_username(request) if request.method == 'POST': new_password = _generate_password(password_length) @@ -100,13 +104,13 @@ def reset_password(request): context_instance=RequestContext(request)) @login_required(login_url='/sso/accounts/login/') -def change_other(request): +def change_other(request, *args): ''' Just passes along the request so that something can be done for that user. ''' username = _get_username(request) if request.method == 'POST': - return_value = _change_other(request) + return_value = _change_other(request, *args) return render_to_response('changepw/change_other.html', {'username': username, 'return_value': return_value}, context_instance=RequestContext(request)) -- cgit v1.1