def adminunblockUser(): try: loginVO = LoginVO() loginDAO = LoginDAO() loginId = request.args.get('loginId') print('loginId::', loginId) loginVO.loginId = loginId registerDAO = RegisterDAO() loginVO.loginRole = 'user' loginVO.loginStatus = 'active' loginDAO.validateLogin(loginVO) registerDAO.viewRegister() loginDAO.unblockUser(loginVO) return redirect(url_for('adminViewUser')) except Exception as ex: print(ex)
def adminValidateLogin(): try: loginUsername = request.form['loginUsername'] loginPassword = request.form['loginPassword'] loginVO = LoginVO() loginDAO = LoginDAO() loginVO.loginUsername = loginUsername loginVO.loginPassword = loginPassword loginVOList = loginDAO.validateLogin(loginVO) loginDictList = [i.as_dict() for i in loginVOList] print(loginDictList) lenLoginDictList = len(loginDictList) if lenLoginDictList == 0: msg = 'Username Or Password is Incorrect !' return render_template('admin/login.html', error=msg) elif loginDictList[0]['loginStatus'] == 'unactive': msg = 'You are BLOCKED.' return render_template('admin/login.html', error=msg) else: for row1 in loginDictList: loginId = row1['loginId'] loginUsername = row1['loginUsername'] loginRole = row1['loginRole'] session['session_loginId'] = loginId session['session_loginUsername'] = loginUsername session['session_loginRole'] = loginRole session.permanent = True if loginRole == 'admin': return redirect(url_for('adminLoadDashboard')) elif loginRole == 'user': return redirect(url_for('userLoadDashboard')) 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.adminUpdateUser(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 adminValidateLogin(): loginUsername = request.form['loginUsername'] loginPassword = request.form['loginPassword'] loginVO = LoginVO() loginDAO = LoginDAO() loginVO.loginUsername = loginUsername loginVO.loginPassword = loginPassword loginVO.loginStatus = "active" loginVOList = loginDAO.validateLogin(loginVO) loginDictList = [i.as_dict() for i in loginVOList] print(loginDictList) lenLoginDictList = len(loginDictList) if lenLoginDictList == 0: msg = 'Username Or Password is Incorrect !' return render_template('admin/Login.html', error=msg) else: for row1 in loginDictList: loginId = row1['loginId'] loginUsername = row1['loginUsername'] loginRole = row1['loginRole'] session['session_loginId'] = loginId session['session_loginUsername'] = loginUsername session['session_loginRole'] = loginRole session.permanent = False if loginRole == 'admin': return redirect(url_for('adminLoadDashboard')) else: return render_template('user/Index.html ')
def validateLogin(): try: print("*******************") loginVO = LoginVO() loginDAO = LoginDAO() username = request.form['username'] password = request.form['password'] print(username) print(password) loginVO.loginUsername = username loginVO.loginPassword = password loginVOList = loginDAO.validateLogin(loginVO) loginDictList = [i.as_dict() for i in loginVOList] lenLoginDictList = len(loginDictList) print(loginDictList) if lenLoginDictList == 0: msg = 'Username and Password is Incorrect !' return render_template('Login.html', error=msg) else: for i in loginDictList: if i['loginUsername'] == username and i[ 'loginPassword'] == password: return render_template('index.html') else: msg1 = 'You are Inactive user !' return render_template('Login.html', error=msg1) except Exception as ex: print(ex)
def adminValidateLogin(): try: loginUsername = request.form['loginUsername'] loginPassword = request.form['loginPassword'] loginVO = LoginVO() loginDAO = LoginDAO() loginVO.loginUsername = loginUsername loginVO.loginPassword = loginPassword loginVO.loginStatus = 'active' loginVOList = loginDAO.validateLogin(loginVO) loginDictList = [i.as_dict() for i in loginVOList] if len(loginDictList) == 0: msg = 'username or password is incorrent !' return render_template('admin/login.html', msg=msg) else: for row in loginDictList: loginId = row['loginId'] loginUsername = row['loginUsername'] loginRole = row['loginRole'] session['session_LoginId'] = loginId session['session_LoginUsername'] = loginUsername session['session_LoginRole'] = loginRole session['session_LoginPassword'] = loginPassword session.permenent = True if loginRole == 'user': return redirect(url_for('userLoadDashboard')) if loginRole == 'admin': return redirect(url_for('adminLoadDashboard')) except Exception as ex: print(ex)