def signup(): sendMail = False pprint.pprint("received signup request") print("Request Data:%s", request.data) credentials = json.loads(request.data) pprint.pprint(credentials) status = db_user_signup(credentials['username'], credentials['password'], credentials['emailaddress']) print(status) if (status == "True" and sendMail == True): mail_text = draft_mail_text("User Registration", credentials['username'], credentials['password']) print "signup:", mail_text sendMail([credentials['emailaddress']], "VNF Onboarding User Registration", mail_text) return status
def sendEmail(): args = json.loads(request.data) recp = args['recp'] subject = args['subject'] uname = args['username'] message = args['message'] s = sendMail(recp, subject, uname, message) return jsonify({'success': True})
def forgetpassword(): print "Received forgetpassword request", request.data inputs = inputs = request.get_json() print "Forgetpassword", inputs status = db_generate_newpassword(inputs, False) print "status=", status if status == 1: print "forgetpassword:user does not exist", status return jsonify({ "Status": "Error", "Message": "Cannot generate password. User does not exist" }) elif status == "Connection Failed": return jsonify({ "Status": "Error", "Message": "Cannot generate passwod.Failure to connect to database" }) elif status == 0: if get_config_param('database.ini', 'Email', 'enablesendemail') == False: print "Email Functionality Disabled" status = db_generate_newpassword(inputs) if status == 0: return jsonify({ "Status": "Error", "Message": "Generated new password.Email Functionality is Disabled.So Password is set to default i.e. password@123" }) mail_text = "" if inputs['username']: print "after updating password", inputs mail_text = draft_mail_text("Forget Password", inputs['username'], inputs['password']) print "forget password:"******"VNF Onboarding New Password", mail_text) == False: status = db_generate_newpassword(inputs) if status == 0: return jsonify({ "Status": "Error", "Message": "New Password set for user.Email Delivery Failed.So Password is set to default i.e. password@123" }) return jsonify({ "Status": "Success", "Message": "New Password generated for user. Email containing credentials has been sent to the user" })
def forgetpassword(): sendMail = False print "Received forgetpassword request", request.data inputs = inputs = request.get_json() print "Forgetpassword", inputs #inputs['password'] = "" status = db_generate_newpassword(inputs) if status == 1: print "forgetpassword:user does not exist", status return "False" elif status == 0 and sendMail == True: mail_text = "" if inputs['username']: print "after updating password", inputs mail_text = draft_mail_text("Forget Password", inputs['username'], inputs['password']) print "forget password:"******"VNF Onboarding New Password", mail_text) print "forgetpassword:new password set", status return "True"
def signup(): pprint.pprint("received signup request") print("Request Data:%s", request.data) credentials = json.loads(request.data) pprint.pprint(credentials) status = db_user_signup(credentials['username'], credentials['password'], credentials['emailaddress']) print(status) if (status == "True"): if get_config_param('database.ini', 'Email', 'enablesendemail') == False: print "Email Functionality Disabled" return jsonify({ "Status": "Success", "Message": "User Registration Succeeded.Email Functionality is Disabled.User can login with new credentials" }) mail_text = draft_mail_text("User Registration", credentials['username'], credentials['password']) print "signup:", mail_text if sendMail([credentials['emailaddress']], "VNF Onboarding User Registration", mail_text) == False: return jsonify({ "Status": "Error", "Message": "User Registration Succeeded.Email Delivery Failed.User can login with new credentials" }) return jsonify({ "Status": "Success", "Message": "User Registration Successful.Email containing credentials has been sent to the user." }) elif status == "Connection Failed": return jsonify({ "Status": "Error", "Message": "User Registration Failed.Failure to connect to database" }) else: return jsonify({ "Status": "Error", "Message": "User Registration Failed. Username or Email-id already exists" })
def sendemail(emaillist, subject, body, otherinfo): finalbody = "Account info : %s \n\n Problem: %s" % (otherinfo, body) for email in emaillist: sendMail(gmailUser, gmailPassword, email, subject, finalbody)
def sendemail(emaillist,subject,body,otherinfo): finalbody = "Account info : %s \n\n Problem: %s" %(otherinfo,body) for email in emaillist: sendMail(gmailUser,gmailPassword,email,subject,finalbody)