X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Fregistrationview.py;h=d3049dda417cc75a9dbaabd65dc1a4df85bf9c04;hb=88561aa60d0e40dc2696825d5f6e4103b7e2a134;hp=e27dfb4d8ca6bd065cbd59bcf188c2d5457494cb;hpb=e6184193b74ac6d5c52289546dae9121bdd99008;p=myslice.git diff --git a/portal/registrationview.py b/portal/registrationview.py index e27dfb4d..d3049dda 100644 --- a/portal/registrationview.py +++ b/portal/registrationview.py @@ -15,7 +15,7 @@ from manifold.manifoldapi import execute_admin_query from manifold.core.query import Query from portal.models import PendingUser -from portal.actions import authority_get_pi_emails +from portal.actions import authority_get_pi_emails, manifold_add_user,manifold_add_account # since we inherit from FreeAccessView we cannot redefine 'dispatch' # so let's override 'get' and 'post' instead @@ -63,7 +63,11 @@ class RegistrationView (FreeAccessView): reg_auth = request.POST.get('authority_hrn', '') reg_login = request.POST.get('login', '') reg_email = request.POST.get('email','').lower() - + #prepare user_hrn + split_email = reg_email.split("@")[0] + split_email = split_email.replace(".", "_") + user_hrn = reg_auth + '.' + split_email + #POST value validation if (re.search(r'^[\w+\s.@+-]+$', reg_fname)==None): errors.append('First Name may contain only letters, numbers, spaces and @/./+/-/_ characters.') @@ -89,7 +93,7 @@ class RegistrationView (FreeAccessView): # private_key = ''.join(private_key.split()) # public_key = "ssh-rsa " + public_key # Saving to DB - keypair = '{"user_public_key":'+ public_key + ', "user_private_key":'+ private_key + '}' + keypair = '{"user_public_key":'+ public_key + ', "user_private_key":'+ private_key + ', "user_hrn":"'+ user_hrn + '"}' #keypair = re.sub("\r", "", keypair) #keypair = re.sub("\n", "\\n", keypair) #keypair = keypair.rstrip('\r\n') @@ -101,7 +105,7 @@ class RegistrationView (FreeAccessView): file_extension = os.path.splitext(file_name)[1] allowed_extension = ['.pub','.txt'] if file_extension in allowed_extension and re.search(r'ssh-rsa',file_content): - keypair = '{"user_public_key":"'+ file_content +'"}' + keypair = '{"user_public_key":"'+ file_content + '", "user_hrn":"'+ user_hrn +'"}' keypair = re.sub("\r", "", keypair) keypair = re.sub("\n", "\\n",keypair) keypair = ''.join(keypair.split()) @@ -113,6 +117,7 @@ class RegistrationView (FreeAccessView): #b = PendingUser(first_name=reg_fname, last_name=reg_lname, affiliation=reg_aff, # email=reg_email, password=request.POST['password'], keypair=keypair) #b.save() + #saving to django db 'portal_pendinguser' table if not errors: b = PendingUser( first_name = reg_fname, @@ -125,17 +130,20 @@ class RegistrationView (FreeAccessView): keypair = keypair, ) b.save() - + #saving to manifold + config = '{"firstname":'+ reg_fname + ', "lastname":'+ reg_lname + ', "authority":"'+ reg_auth + '"}' + user_params = {'email': reg_email, 'password': request.POST['password'], 'config': config} + manifold_add_user(request,user_params) # Send email ctx = { 'first_name' : reg_fname, 'last_name' : reg_lname, 'authority_hrn' : reg_auth, - 'email' : reg_email, + 'email' : reg_email, + 'user_hrn' : user_hrn, 'keypair' : 'Public Key :' + public_key, 'cc_myself' : True # form.cleaned_data['cc_myself'] } - recipients = authority_get_pi_emails(request,reg_auth) if ctx['cc_myself']: