def updateProfile(): if session['loginRole'] != 'user': return redirect(url_for('login')) loginDAO = LoginDAO() loginVO = LoginVO() registerDAO = RegisterDAO() registerVO = RegisterVO() loginVO.loginId = session['loginId'] loginVO.loginEmailId = request.form['registerEmailId'] loginVO.loginActiveStatus = 'active' registerVO.register_LoginId = session['loginId'] registerVO.registerFirstName = request.form['registerFirstName'] registerVO.registerLastName = request.form['registerLastName'] registerVO.registerContact = request.form['registerContact'] registerVO.registerActiveStatus = 'active' registerDAO.updateRegister(registerVO) loginDAO.updateLogin(loginVO) return redirect(url_for('userProfile'))
def insertRegister(): registerDAO = RegisterDAO() registerVO = RegisterVO() loginDAO = LoginDAO() loginVO = LoginVO() loginVO.loginEmailId = request.form['registerEmailId'] loginDict = loginDAO.searchLoginByEmailId(loginVO) if loginDict: flash('EmailAddress Is Already Taken', 'success') return render_template('admin/register.html') registerVO.registerFirstName = request.form['registerFirstName'] registerVO.registerLastName = request.form['registerLastName'] registerVO.registerContact = request.form['registerContact'] registerVO.registerDate, registerVO.registerTime = str( datetime.now()).split(' ') registerVO.registerActiveStatus = 'active' loginVO.loginRole = 'user' loginVO.loginActiveStatus = 'active' loginVO.loginPassword = '******' loginDAO.insertLogin(loginVO) loginDict = loginDAO.getMaxId() registerVO.register_LoginId = loginDict[0]['MAX(loginId)'] registerDAO.insertRegister(registerVO) loginDict = loginDAO.searchLoginByEmailId(loginVO) session['loginRole'] = loginDict[0]['loginRole'] session['loginId'] = loginDict[0]['loginId'] fromaddr = "*****@*****.**" toaddr = loginVO.loginEmailId msg = MIMEMultipart() msg['From'] = fromaddr msg['To'] = toaddr msg['Subject'] = "welcome to lemanhouse" msg.attach(MIMEText(loginVO.loginPassword, 'plain')) server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login("*****@*****.**", "HeisenBerg_1102008") text = msg.as_string() server.sendmail(fromaddr, toaddr, text) server.quit() return redirect(url_for('home'))
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'))