def updateProfile(): try: registerDAO = RegisterDAO() registerVO = RegisterVO() loginDAO = LoginDAO() loginVO = LoginVO() registerVO.registerFirstName = request.form['registerFirstName'] registerVO.registerLastName = request.form['registerLastName'] registerVO.registerGender = request.form['registerGender'] registerVO.registerAddress = request.form['registerAddress'] registerVO.registerPincode = request.form['registerPincode'] registerVO.registerContact = request.form['registerContact'] loginVO.loginEmailId = request.form['registerEmailId'] loginVO.loginPassword = request.form['loginPassword'] loginVO.loginId = registerVO.register_LoginId = request.form['loginId'] loginDict = loginDAO.searchLoginIddata(loginVO) if loginVO.loginPassword == loginDict[0]['loginPassword']: loginDAO.updateProfile(loginVO) registerDAO.updateProfile(registerVO) return redirect(url_for('loadProfile')) else: session['error'] = "*wrong password Please enter again" return redirect(url_for('loadEditprofile')) except: return render_template('admin/login.html')
def insertRegister(): registerVO = RegisterVO() registerDAO = RegisterDAO() loginVO = LoginVO() loginDAO = LoginDAO() alphabet = string.ascii_letters + string.digits password = ''.join(choice(alphabet) for i in range(8)) registerVO.registerName = request.form['registerName'] registerVO.registerAddress = request.form['registerAddress'] registerVO.registerGender = request.form['registerGender'] registerVO.registerArea = request.form['registerArea'] registerVO.registerCity = request.form['registerCity'] registerVO.registerPincode = request.form['registerPincode'] registerVO.registerMobileno = request.form['registerMobileno'] registerVO.registerEmail = request.form['registerEmail'] registerVO.registerActivestatus = 'active' print("Hello i am Seller") loginVO.loginEmail = request.form['registerEmail'] loginVO.loginPassword = password loginVO.loginRole = 'seller' loginVO.loginActivestatus = 'active' print('EMAIL', loginVO.loginEmail) print("password", loginVO.loginPassword) print("role", loginVO.loginRole) print("status", loginVO.loginActivestatus) loginDict = loginDAO.loadlogin(loginVO) print(loginDict) fromaddr = "*****@*****.**" #email msg = MIMEMultipart() msg['From'] = fromaddr msg['To'] = loginVO.loginEmail msg['Subject'] = "PASSWORD FOR YOUR LOGIN" msg.attach(MIMEText(loginVO.loginPassword, 'plain')) server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() passw = "hardik@4693" #password server.login(fromaddr, passw) text = msg.as_string() server.sendmail(fromaddr, loginVO.loginEmail, text) server.quit() loginDict = loginDAO.searchloginId() print(loginDict) registerVO.register_loginId = str(loginDict) registerDAO.insertRegister(registerVO) return render_template('admin/login.html')
def insertRegister(): registerDAO = RegisterDAO() registerVO = RegisterVO() loginDAO = LoginDAO() loginVO = LoginVO() loginVO.loginEmailId = request.form['registerEmailId'] registerDict = loginDAO.searchLogin(loginVO) if len(registerDict) > 0: return render_template('user/register.html', errorreg="*already registered") else: registerVO.registerFirstName = request.form['registerFirstName'] registerVO.registerLastName = request.form['registerLastName'] registerVO.registerGender = request.form['registerGender'] registerVO.registerAddress = request.form['registerAddress'] registerVO.registerPincode = request.form['registerPincode'] registerVO.registerContact = request.form['registerContact'] registerVO.registerDate, registerVO.registerTime = str( datetime.now()).split(' ') registerVO.registerActiveStatus = 'active' loginVO.loginRole = 'user' loginVO.loginActiveStatus = 'active' loginVO.loginPassword = ''.join( (random.choice(string.ascii_letters + string.digits)) for x in range(8)) fromaddr = "*****@*****.**" toaddr = loginVO.loginEmailId msg = MIMEMultipart() msg['From'] = fromaddr msg['To'] = toaddr msg['Subject'] = "your password" msg.attach(MIMEText(loginVO.loginPassword, 'plain')) server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login(fromaddr, "iamdarshil") text = msg.as_string() server.sendmail(fromaddr, toaddr, text) server.quit() loginDAO.insertLogin(loginVO) loginDict = loginDAO.searchLoginId() registerVO.register_LoginId = loginDict[0]['max(loginId)'] registerDAO.insertRegister(registerVO) return redirect(url_for('loadLogin')) return redirect(url_for('loadLogin'))