Permalink
Browse files

Downloading of newly created User Cert now works.

  • Loading branch information...
1 parent 7246cf4 commit cd2b2a87e3a5f8bf6e7677f9b93c277a0ae8550e @clemesha-ooi clemesha-ooi committed Feb 22, 2010
@@ -12,7 +12,7 @@
from nimbusrest.admin.connection import AdminConnection
-def create_user(dn, username, email, firstname, lastname):
+def create_user(dn, cert, key, username, email, firstname, lastname):
"""
Returns (error_text, new_user, success_token)
"""
@@ -27,9 +27,11 @@ def create_user(dn, username, email, firstname, lastname):
user.dn = dn #XXX hack
nimbus_user = nimbus_user_create_remote(user)
+ access_key_obj = nimbus_user.generate_access_key()
+ query_id, query_secret = access_key_obj.key, access_key_obj.secret
print "[create_user] nimbus_user => ", nimbus_user
token = _generate_login_key()
- _insert_user_profile_data(user, token=token)
+ _insert_user_profile_data(user, token=token, cert=cert, key=key, query_id=query_id, query_secret=query_secret)
return (None, user, token)
@@ -73,7 +75,7 @@ def _generate_initial_password():
return password
def _generate_login_key():
- okchars = string.letters + string.digits + "_+-"
+ okchars = string.letters + string.digits + "_-"
okchars += okchars
token = ''.join(Random().sample(okchars, 80)).replace(" ", "_")
return token
@@ -24,7 +24,7 @@ def method(request, method):
if method not in ["cert", "dn", "autocreate"]:
raise Http404
- dn = None
+ dn, cert, key = None, None, None
if method == "cert":
methodinfo = USER_CREATE_METHODS[0][1]
if request.method == "POST":
@@ -53,10 +53,19 @@ def method(request, method):
form = AutoCreateForm(request.POST)
if form.is_valid():
cn = form.cleaned_data["username"] #username is used as the CN (common name)
+ print "[autocreate] cn => ", cn
try:
(dn, cert, key) = autocreate_cert(cn)
except:
- raise Exception("Failed autocreating new cert and key.") #TODO: better error.
+ exception_type = sys.exc_type
+ try:
+ exceptname = exception_type.__name__
+ except AttributeError:
+ exceptname = exception_type
+ name = str(exceptname)
+ err = str(sys.exc_value)
+ errmsg = "Problem creating User: '%s: %s'" % (name, err)
+ raise Exception(errmsg)
else:
form = AutoCreateForm()
@@ -66,7 +75,7 @@ def method(request, method):
firstname = form.cleaned_data["firstname"]
lastname = form.cleaned_data["lastname"]
email = form.cleaned_data["email"]
- (error, new_user, token) = create_user(dn, username, email, firstname, lastname)
+ (error, new_user, token) = create_user(dn, cert, key, username, email, firstname, lastname)
if error:
raise Exception(error)
return HttpResponseRedirect("/usercreate/success?token="+token)
@@ -92,3 +101,7 @@ def success(request):
basepath = getattr(settings, "NIMBUS_PRINT_PATH", "register/token/")
url = baseurl+basepath
return render_to_response('usercreate/success.html', {"url":url, "token":token})
+
+
+
+

0 comments on commit cd2b2a8

Please sign in to comment.