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 userValidateOTP(): try: passwordOTP = request.form['passwordOTP'] if passwordOTP == session['session_OTP']: loginPassword = ''.join( (random.choice(string.ascii_letters + string.digits)) for x in range(8)) loginUsername = session['session_loginUsername'] sender = "*****@*****.**" receiver = loginUsername msg = MIMEMultipart() msg['From'] = sender msg['To'] = receiver msg['subject'] = "Reset Password" msg.attach(MIMEText('Your new Password is:')) msg.attach(MIMEText(loginPassword, 'plain')) server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login(sender, "parents123eye123") text = msg.as_string() server.sendmail(sender, receiver, text) server.quit() loginVO = LoginVO() loginDAO = LoginDAO() loginVO.loginUsername = loginUsername loginVO.loginId = session['session_loginId'] loginVO.loginPassword = loginPassword loginDAO.updateLogin(loginVO) return render_template( "admin/login.html", error="Your new password is sent to your email address!") else: return render_template('admin/login.html', error="Invalid OTP,Please ty again!") except Exception as ex: print(ex)
def adminUpdatePassword(): loginVO = LoginVO() loginDAO = LoginDAO() password1 = request.form['password1'] password2 = request.form['password2'] if password1 == password2: loginVO.loginId = session['session_LoginId'] loginVO.loginPassword = password1 loginDAO.updateLogin(loginVO) return render_template('admin/login.html', msg="Password Reset") else: return render_template('admin/resetPassword.html', msg="Password Mismatch")
def adminBlockUser(): try: if adminLoginSession() == 'admin': loginId = request.args.get('loginId') loginStatus = 'unactive' loginVO = LoginVO() loginDAO = LoginDAO() loginVO.loginId = loginId loginVO.loginStatus = loginStatus loginDAO.updateLogin(loginVO) return redirect(url_for('adminViewUser')) else: return redirect(url_for('adminLogoutSession')) except Exception as ex: print(ex)
def adminUpdateTrafficPoliceStation(): try: if adminLoginSession() == 'admin': trafficPoliceStationId = request.form['trafficPoliceStationId'] trafficPoliceStationUsername = request.form[ 'trafficPoliceStationUsername'] trafficPoliceStationName = request.form['trafficPoliceStationName'] trafficPoliceStation_AreaId = request.form[ 'trafficPoliceStation_AreaId'] trafficPoliceStationAddress = request.form[ 'trafficPoliceStationAddress'] trafficPoliceStationContact = request.form[ 'trafficPoliceStationContact'] trafficPoliceStation_LoginId = request.form[ 'trafficPoliceStation_LoginId'] trafficPoliceStationVO = TrafficPoliceStationVO() trafficPoliceStationDAO = TrafficPoliceStationDAO() loginVO = LoginVO() loginDAO = LoginDAO() loginVO.loginId = trafficPoliceStation_LoginId loginVOList = loginDAO.registerLogin(loginVO) loginDictList = [i.as_dict() for i in loginVOList] loginVO.loginId = loginDictList[0]['loginId'] loginVO.loginUsername = trafficPoliceStationUsername loginVO.loginPassword = loginDictList[0]['loginPassword'] loginVO.loginStatus = loginDictList[0]['loginStatus'] loginVO.loginRole = loginDictList[0]['loginRole'] loginDAO.updateLogin(loginVO) trafficPoliceStationVO.trafficPoliceStationId = trafficPoliceStationId trafficPoliceStationVO.trafficPoliceStationName = trafficPoliceStationName trafficPoliceStationVO.trafficPoliceStationAddress = trafficPoliceStationAddress trafficPoliceStationVO.trafficPoliceStationContact = trafficPoliceStationContact trafficPoliceStationVO.trafficPoliceStation_AreaId = trafficPoliceStation_AreaId trafficPoliceStationVO.trafficPoliceStation_LoginId = trafficPoliceStation_LoginId trafficPoliceStationDAO.updateTrafficPoliceStation( trafficPoliceStationVO) return redirect(url_for('adminViewTrafficPoliceStation')) else: adminLogoutSession() except Exception as ex: print(ex)
def userResetPassword(): try: if adminLoginSession() == 'user': oldLoginPassword = request.form['oldLoginPassword'] newLoginPassword = request.form['newLoginPassword'] confirmNewLoginPassword = request.form['confirmNewLoginPassword'] loginVO = LoginVO() loginDAO = LoginDAO() loginVO.loginId = session['session_loginId'] print(loginVO.loginId) loginVO.loginUsername = session['session_loginUsername'] print(loginVO.loginUsername) loginVO.loginPassword = oldLoginPassword print(loginVO.loginPassword) loginDictList = [ i.as_dict() for i in loginDAO.validateLogin(loginVO) ] print(loginDictList) if len(loginDictList) != 0: print([i.as_dict() for i in loginDAO.validateLogin(loginVO)]) if newLoginPassword == confirmNewLoginPassword: loginVO.loginPassword = newLoginPassword loginDAO.updateLogin(loginVO) return render_template("user/index.html") else: return render_template( 'user/resetPassword.html', error= "Invalid confirmation of new password,Please try again!" ) else: return render_template( 'user/resetPassword.html', error="Invalid old password,please enter valid Password!") else: return redirect(url_for("adminLogoutSession")) except Exception as ex: print(ex)
def userCheckPassword(): if adminLoginSession() == 'user': oldPassword = request.form['oldPassword'] newPassword1 = request.form['newPassword1'] newPassword2 = request.form['newPassword2'] loginVO = LoginVO() loginDAO = LoginDAO() if oldPassword == session['session_LoginPassword']: if newPassword1 == newPassword2: loginVO.loginId = session['session_LoginId'] loginVO.loginPassword = newPassword1 loginDAO.updateLogin(loginVO) return render_template('admin/login.html', msg="Password Reset") else: return render_template('user/resetPassword.html', msg="Password Mismatch") else: return render_template('user/resetPassword.html', msg="Current Password not Valid") else: adminLogoutSession()
def adminUpdateTrafficPoliceStation(): try: if adminLoginSession() == 'admin': loginVO = LoginVO() loginDAO = LoginDAO() trafficPoliceStationVO = TrafficPoliceStationVO() trafficPoliceStationDAO = TrafficPoliceStationDAO() trafficPoliceStationId = request.form['trafficPoliceStationId'] trafficPoliceStationName = request.form['trafficPoliceStationName'] trafficPoliceStationContact = request.form['trafficPoliceStationContact'] trafficPoliceStation_AreaId = request.form['trafficPoliceStation_AreaId'] trafficPoliceStationAddress = request.form['trafficPoliceStationAddress'] loginId = request.form['loginId'] loginUsername = request.form['loginUsername'] loginVO.loginId = loginId loginVO.loginUsername = loginUsername loginDAO.updateLogin(loginVO) trafficPoliceStationVO.trafficPoliceStationId = trafficPoliceStationId trafficPoliceStationVO.trafficPoliceStationName = trafficPoliceStationName trafficPoliceStationVO.trafficPoliceStationContact = trafficPoliceStationContact trafficPoliceStationVO.trafficPoliceStation_AreaId = trafficPoliceStation_AreaId trafficPoliceStationVO.trafficPoliceStationAddress = trafficPoliceStationAddress trafficPoliceStationVO.trafficPoliceStation_LoginId = loginId trafficPoliceStationDAO.updateTrafficPoliceStation(trafficPoliceStationVO) return redirect(url_for('adminViewTrafficPoliceStation')) else: return adminLogoutSession() except Exception as ex: print(ex)
def userUpdateRegister(): try: if adminLoginSession() == 'user': registerVO = RegisterVO() registerDAO = RegisterDAO() loginId = request.form['loginId'] loginUsername = request.form['loginUsername'] registerId = request.form['registerId'] registerFirstName = request.form['registerFirstName'] registerLastName = request.form['registerLastName'] registerAddress = request.form['registerAddress'] registerContact = request.form['registerContact'] loginVO = LoginVO() loginDAO = LoginDAO() loginVO.loginId = loginId loginList = loginDAO.viewLogin(loginVO) if loginList[0].loginUsername == loginUsername: pass else: loginPassword = ''.join( (random.choice(string.ascii_letters + string.digits)) for x in range(8)) sender = "*****@*****.**" receiver = loginUsername msg = MIMEMultipart() msg['From'] = sender msg['To'] = receiver msg['Subject'] = "ACCOUNT PASSWORD" msg.attach(MIMEText(loginPassword, 'plain')) server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login(sender, "parents123eye123") text = msg.as_string() server.sendmail(sender, receiver, text) server.quit() loginVO.loginUsername = loginUsername loginVO.loginPassword = loginPassword loginDAO.updateLogin(loginVO) registerVO.registerId = registerId registerVO.registerFirstName = registerFirstName registerVO.registerLastName = registerLastName registerVO.registerAddress = registerAddress registerVO.registerContact = registerContact registerDAO.updateRegister(registerVO) return redirect(url_for('userLoadDashboard')) else: return adminLogoutSession() except Exception as ex: print(ex)