results = execute_admin_query(request, query)
return [result['user_email'] for result in results]
+#clear user credentials
+def clear_user_creds(request, user_email):
+ try:
+ user_query = Query().get('local:user').filter_by('email', '==', user_email).select('user_id','email','password','config')
+ user_details = execute_admin_query(request, user_query)
+
+ # getting the user_id from the session
+ for user_detail in user_details:
+ user_id = user_detail['user_id']
+ user_email = user_detail['email']
+
+ account_query = Query().get('local:account').filter_by('user_id', '==', user_id).select('user_id','platform_id','auth_type','config')
+ account_details = execute_admin_query(request, account_query)
+
+ platform_query = Query().get('local:platform').select('platform_id','platform')
+ platform_details = execute_admin_query(request, platform_query)
+
+ for account_detail in account_details:
+ for platform_detail in platform_details:
+ 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')
+ 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'))
+ user_priv_key = json.dumps(account_config.get('user_private_key','N/A'))
+ updated_config = '{"user_public_key":'+ user_pub_key + ', "user_private_key":'+ user_priv_key + ', "user_hrn":"'+ user_hrn + '"}'
+ user_params = { 'config': updated_config}
+ manifold_update_account(request, user_id,user_params)
+ return user_email
+ else:
+ return None
+
+ except Exception,e:
+ print "Exception in actions.py in clear_user_creds %s" % e
+ return None
+
def is_pi(wsgi_request, user_hrn, authority_hrn):
# XXX could be done in a single query !
?
"""
+
+ authority_hrn = request['authority_hrn']
+ request['authority_hrn'] = authority_hrn.split(".")[0]
+
USER_CONFIG = '{"firstname": "%(first_name)s", "lastname": "%(last_name)s", "authority": "%(authority_hrn)s"}'
user_params = {
'status' : 1,
}
+ request['authority_hrn'] = authority_hrn
+
query = Query.create('local:user').set(user_params).select('email')
results = execute_admin_query(request, query)
if not results:
subject = render_to_string(theme.template, request)
subject = subject.replace('\n', '')
- sender = email
+ theme.template_name = 'email_default_sender.txt'
+ sender = render_to_string(theme.template, request)
+ sender = sender.replace('\n', '')
+
+ #sender = email
msg = EmailMultiAlternatives(subject, text_content, sender, recipients)
msg.attach_alternative(html_content, "text/html")
msg.send()
else:
subject = 'User validated'
msg = 'A manager of your institution has validated your account. You have now full user access to the portal.'
- send_mail(subject, msg, 'support@onelab.eu',[request['email']], fail_silently=False)
+ send_mail(subject, msg, 'support@fibre.org.br',[request['email']], fail_silently=False)
return results
def ldap_create_user(wsgi_request, request, user_detail):
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, request['authority_hrn'])
+
+ split_authority_hrn = request['authority_hrn'].split(".")[0]
+
+ recipients = authority_get_pi_emails(wsgi_request, split_authority_hrn)
theme.template_name = 'user_request_email.html'
html_content = render_to_string(theme.template, request)