Restricts service account usernames to charnames

* Forms now show a character selection box
  * Once created, user is sent to a template with a generated password
  * Will not display a service if a account already exists on it.
This commit is contained in:
2010-03-12 12:16:07 +00:00
parent 5d58897848
commit cb49170d33
4 changed files with 55 additions and 34 deletions

View File

@@ -1,3 +1,5 @@
import hashlib
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.core.urlresolvers import reverse
@@ -97,14 +99,16 @@ def service_add(request):
acc.user = request.user
acc.service = form.cleaned_data['service']
acc.username = form.cleaned_data['username']
acc.password = form.cleaned_data['password']
acc.password = hashlib.sha1('%s%s' % form.cleaned_data['service'].name, request.user.username).hexdigest()
try:
acc.save()
except ExistingUser:
pass
return HttpResponseRedirect(reverse('sso.views.profile')) # Redirect after POST
error = "User by this name already exists, your account has not been created"
else:
error = None
return render_to_response('sso/serviceaccount_created.html', { 'account': acc, 'error': error })
else:
#defaults = { 'username': request.user.username, 'password': request.user.get_profile().default_service_passwd }
form = clsform() # An unbound form