mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-18 12:19:29 +00:00
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:
12
sso/views.py
12
sso/views.py
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user