return HttpResponseRedirect("/portal/account/")
# XXX TODO: Factorize with portal/registrationview.py
+# XXX TODO: Factorize with portal/registrationview.py
+# XXX TODO: Factorize with portal/joinview.py
elif 'generate' in request.POST:
for account_detail in account_details:
#prepare user_hrn
split_email = reg_email.split("@")[0]
split_email = split_email.replace(".", "_")
+ # Replace + by _ => more convenient for testing and validate with a real email
+ split_email = split_email.replace("+", "_")
user_hrn = reg_auth + '.' + split_email
UserModel = get_user_model()
errors.append('Email already registered in Manifold. Please provide a new email address.')
# XXX TODO: Factorize with portal/accountview.py
+# XXX TODO: Factorize with portal/registrationview.py
+# XXX TODO: Factorize with portal/joinview.py
# if 'generate' in request.POST['question']:
from Crypto.PublicKey import RSA
private = RSA.generate(1024)
- private_key = json.dumps(private.exportKey())
- public = private.publickey()
- public_key = json.dumps(public.exportKey(format='OpenSSH'))
-
+ private_key = private.exportKey()
+ public_key = private.publickey().exportKey(format='OpenSSH')
# Saving to DB
- account_config = '{"user_public_key":'+ public_key + ', "user_private_key":'+ private_key + ', "user_hrn":"'+ user_hrn + '"}'
auth_type = 'managed'
- public_key = public_key.replace('"', '');
- private_key = private_key.replace('"', '');
if not errors:
reg_password = request.POST['pi_password']
# Construct user_hrn from email (XXX Should use common code)
split_email = user_request['email'].split("@")[0]
split_email = split_email.replace(".", "_")
+ # Replace + by _ => more convenient for testing and validate with a real email
split_email = split_email.replace("+", "_")
user_request['user_hrn'] = user_request['authority_hrn'] \
+ '.' + split_email
+ '.' + split_email + str(randint(1,1000000))
# XXX TODO: Factorize with portal/accountview.py
+ # XXX TODO: Factorize with portal/registrationview.py
+ # XXX TODO: Factorize with portal/joinview.py
if 'generate' in wsgi_request.POST['question']:
user_request['auth_type'] = 'managed'
purpose=''
exp_url=''
authority_hrn = None
+ authority_name = None
# Retrieve the list of authorities
authorities_query = Query.get('authority').select('name', 'authority_hrn')
authorities = execute_admin_query(wsgi_request, authorities_query)
if authority['authority_hrn'] == user_authority:
authority_name = authority['name']
+ # Handle the case when we use only hrn and not name
+ if authority_name is None:
+ authority_name = user_authority
#
account_query = Query().get('local:account').select('user_id','platform_id','auth_type','config')
account_details = execute_query(wsgi_request, account_query)
if authority['name'] == wsgi_request.POST.get('org_name', ''):
authority_hrn = authority['authority_hrn']
- # Handle the case when the template uses only hrn and not name
+ # Handle the case when we use only hrn and not name
if authority_hrn is None:
authority_hrn = wsgi_request.POST.get('org_name', '')