admin_user, admin_password = ConfigEngine().manifold_admin_user_password()
manifold_api_session_auth = {'AuthMethod': 'password', 'Username': admin_user, 'AuthString': admin_password}
else:
- print request.session['manifold']
- manifold_api_session_auth = request.session['manifold']['auth']
-
+ if 'manifold' in request.session:
+ manifold_api_session_auth = request.session['manifold']['auth']
+ else:
+ json_answer=json.dumps({'code':0,'value':[]})
+ return HttpResponse (json_answer, mimetype="application/json")
+
if debug_empty and manifold_query.action.lower()=='get':
json_answer=json.dumps({'code':0,'value':[]})
print "By-passing : debug_empty & 'get' request : returning a fake empty list"
if platform_detail['platform_id'] == account_detail['platform_id']:
if 'myslice' in platform_detail['platform']:
account_config = json.loads(account_detail['config'])
- user_cred = account_config.get('delegated_user_credential','N/A')
+ #user_cred = account_config.get('delegated_user_credential','N/A')
+ user_cred = account_config.get('user_credential','N/A')
if 'N/A' not in user_cred:
user_hrn = account_config.get('user_hrn','N/A')
user_pub_key = json.dumps(account_config.get('user_public_key','N/A'))
query = Query.create('%s:user' % namespace).set(sfa_user_params).select('user_hrn')
else:
query = Query.create('user').set(sfa_user_params).select('user_hrn')
+
if as_admin:
- results = execute_query(wsgi_request, query)
- else:
results = execute_admin_query(wsgi_request, query)
+ else:
+ results = execute_query(wsgi_request, query)
if not results:
raise Exception, "Could not create %s. Already exists ?" % sfa_user_params['user_hrn']
return results
def create_user(wsgi_request, request, namespace = None, as_admin = False):
-
# XXX This has to be stored centrally
USER_STATUS_ENABLED = 2
#print "%s = %s" % (key, value)
if key == "hash_code":
hash_code=value
-
if PendingUser.objects.filter(email_hash__iexact = hash_code).filter(status__iexact = 'False'):
+ activation = 'success'
+ PendingUser.objects.filter(email_hash__iexact = hash_code).update(status='True')
+
# AUTO VALIDATION of PLE enabled users (only for OneLab Portal)
if self.theme == "onelab":
# Auto-Validation of pending user, which is enabled in a trusted SFA Registry (example: PLE)
if pending_users:
pending_user = pending_users[0]
pending_user_request = make_request_user(pending_user)
- pending_user_email = pending_users[0].user_email
+ pending_user_email = pending_users[0].email
query = Query.get('myplcuser').filter_by('email', '==', pending_user_email).select('enabled')
results = execute_admin_query(self.request, query)
for result in results:
# User is enabled in PLE
- if 'user_enabled' in result and result['user_enabled']==True:
+ if 'enabled' in result and result['enabled']==True:
ple_user_enabled = True
break
else:
# Create user in SFA and Update in Manifold
create_user(self.request, pending_user_request, namespace = 'myslice', as_admin = True)
# Delete pending user
- PendingUser.objects.filter(email_hash__iexact = hash_code).delete()
+ #PendingUser.objects.filter(email_hash__iexact = hash_code).delete()
- #get_user.status= 'True'
- #get_user.save()
- #for user in PendingUser.objects.all():
- # first_name = user.first_name
- # last_name = user.last_name
- # authority_hrn = user.authority_hrn
- # public_key = user.public_key
- # email = user.email
- # user_hrn = user.user_hrn
- PendingUser.objects.filter(email_hash__iexact = hash_code).update(status='True')
- activation = 'success'
- # sending email after activation success
- #try:
- # Send an email: the recipients are the PI of the authority
- # If No PI is defined for this Authority, send to a default email (different for each theme)
- # recipients = authority_get_pi_emails(wsgi_request, authority_hrn)
- # theme.template_name = 'user_request_email.html'
- # html_content = render_to_string(theme.template, request)
- # theme.template_name = 'user_request_email.txt'
- # text_content = render_to_string(theme.template, request)
- # theme.template_name = 'user_request_email_subject.txt'
- # subject = render_to_string(theme.template, request)
- # subject = subject.replace('\n', '')
- # theme.template_name = 'email_default_sender.txt'
- # sender = render_to_string(theme.template, request)
- # sender = sender.replace('\n', '')
- # msg = EmailMultiAlternatives(subject, text_content, sender, recipients)
- # msg.attach_alternative(html_content, "text/html")
- # msg.send()
- # except Exception, e:
- # print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
- # import traceback
- # traceback.print_exc()
+ # template user auto validated
+ activation = 'validated'
+ # sending email after activation success
+ #try:
+ # # Send an email: the recipient is the user
+ # recipients = pending_user_eamil
+ # theme.template_name = 'user_request_email.html'
+ # html_content = render_to_string(theme.template, request)
+ # theme.template_name = 'user_request_email.txt'
+ # text_content = render_to_string(theme.template, request)
+ # theme.template_name = 'user_request_email_subject.txt'
+ # subject = render_to_string(theme.template, request)
+ # subject = subject.replace('\n', '')
+ # theme.template_name = 'email_default_sender.txt'
+ # sender = render_to_string(theme.template, request)
+ # sender = sender.replace('\n', '')
+ # msg = EmailMultiAlternatives(subject, text_content, sender, recipients)
+ # msg.attach_alternative(html_content, "text/html")
+ # msg.send()
+ #except Exception, e:
+ # print "Failed to send email, please check the mail templates and the SMTP configuration of your server"
+ # import traceback
+ # traceback.print_exc()
+
else:
activation = 'failed'
errors.append('First name may contain only letters, numbers, spaces and @/./+/-/_ characters.')
if (re.search(r'^[\w+\s.@+-]+$', user_request['last_name']) == None):
errors.append('Last name may contain only letters, numbers, spaces and @/./+/-/_ characters.')
- # checking in django_db !!
- if PendingUser.objects.filter(email__iexact = user_request['email']):
- errors.append('Email is pending for validation. Please provide a new email address.')
- if UserModel._default_manager.filter(email__iexact = user_request['email']):
- errors.append('This email is not usable. Please contact the administrator or try with another email.')
# Does the user exist in Manifold?
user_query = Query().get('local:user').select('user_id','email')
user_details = execute_admin_query(wsgi_request, user_query)
for user_detail in user_details:
if user_detail['email'] == user_request['email']:
- errors.append('Email already registered in Manifold. Please provide a new email address.')
+ errors.append('Email already registered. <a href="/">Login</a> with your existing account. <a href="/portal/pass_reset/">Forgot your password?</a>')
+
# Does the user exist in sfa? [query is very slow!!]
#user_query = Query().get('user').select('user_hrn','user_email')
# XXX Test based on the user_hrn is quick
for user in user_details_sfa:
if user['user_email'] == user_request['email']:
- errors.append('Email already registered in SFA registry. Please use another email.')
+ errors.append('Email already registered in OneLab registry. <a href="/contact">Contact OneLab support</a> or use another email.')
if user['user_hrn'] == user_request['user_hrn']:
# add random number if user_hrn already exists in the registry
user_request['user_hrn'] = user_request['authority_hrn'] \
+ '.' + split_email + str(randint(1,1000000))
-
+
+ # checking in django unfold db portal application pending users
+ # sqlite3 /var/unfold/unfold.sqlite3
+ # select email from portal_pendinguser;
+ if PendingUser.objects.filter(email__iexact = user_request['email']):
+ errors.append('Account pending for validation. Please wait till your account is validated or contact OneLab support.')
+
+ # checking in django_db !!
+ # sqlite3 /var/unfold/unfold.sqlite3
+ # select email from auth_user;
+ if UserModel._default_manager.filter(email__iexact = user_request['email']):
+ errors.append('<a href="/contact">Contact OneLab support</a> or try with another email.')
+
# XXX TODO: Factorize with portal/accountview.py
# XXX TODO: Factorize with portal/registrationview.py
# XXX TODO: Factorize with portal/joinview.py
</div>
</div>
</div>
-</div>
\ No newline at end of file
+</div>
<h1><img src="{{ STATIC_URL }}img/icon_user_small.png" alt="User Registration" />User sign-up</h1>
</div>
<div class="row">
- {%if activation_status == 'success'%}
+ {% if activation_status == 'success' %}
<h3>Signup request confirmed.</h3>
<p>You are currently able to log in to the portal using your email address and the password that you provided, but your access is still limited.</p>
<p>You will have full access as soon as your account is validated by a manager at your organization. We have sent an email to the managers with a validation request.</p>
+ {% elif activation_status == 'validated' %}
+ <h3>Account validated.</h3>
+ <p>We have identified you as a valid PLE user. Your OneLab account has automatically been approved.</p>
+ <p>You have a full access to OneLab testbeds.</p>
{%else%}
<h3>Signup confirmation failed.</h3>
<p>You have probably arrived at this page by clicking a confirmation link in an email that we have sent to you. However,
{% if errors %}
<div class="row">
<div class="col-md-12">
- <ul>
+ <ul class="error">
{% for error in errors %}
- <li style="color:white;">{{ error }}</li>
+ <li>{{ error | safe }}</li>
{% endfor %}
</ul>
</div>
if (action == 'clear') :
res=[]
emails = request.POST.getlist('emails[]')
+ if not emails:
+ emails = request.GET.getlist('emails[]')
+ import pdb
+ pdb.set_trace()
if emails :
for email in emails :
try :
- res.append(clear_user_creds(request, email))
+ clear = clear_user_creds(request, email)
+ if clear is not None:
+ res.append(clear)
except :
pass
if not res :
- ret = { "ret" : 1, "emails" : res }
+ ret = { "ret" : 1, "emails" : emails }
else :
ret = { "ret" : 0 }