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'] == 'inactive':
            msg = 'You are temporarily blocked by admin!'

            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)
Ejemplo n.º 2
0
def userProfile():

    if session['loginRole'] != 'user':
        return redirect(url_for('login'))

    loginDAO = LoginDAO()
    loginVO = LoginVO()

    loginVO.loginId = session['loginId']
    loginDict = loginDAO.searchLoginDetailsById(loginVO)
    print "loginDict : ", loginDict
    return render_template('user/user-profile.html', loginDict=loginDict)
Ejemplo n.º 3
0
def userupdatePassword():
    try:
        if adminLoginSession() == 'user':

            oldPassword = request.form['oldPassword']
            newPassword = request.form['newPassword']
            confirmPassword = request.form['confirmPassword']

            loginId = session['session_loginId']
            loginUsername = session['session_loginUsername']

            loginVO = LoginVO()
            loginDAO = LoginDAO()

            loginVO.loginUsername = loginUsername

            loginVOList = loginDAO.loginUsername(loginVO)

            loginDictList = [i.as_dict() for i in loginVOList]

            print(loginDictList)

            for row in loginDictList:
                loginPassword = row['loginPassword']

                session['session_loginPassword'] = loginPassword

                session.permanent = True

                if session['session_loginPassword'] == oldPassword:
                    if newPassword == confirmPassword:

                        loginVO.loginId = loginId
                        loginVO.loginPassword = confirmPassword
                        loginDAO.updatePassword(loginVO)

                        return redirect(url_for('userLoadDashboard'))

                    else:
                        msg = "Your New and Confirm Password does not match!!!"
                        return render_template('user/changePassword.html',
                                               error=msg)
                else:
                    msg = "Your Old password is Incorrect!!!"
                    return render_template('user/changePassword.html',
                                           error=msg)

        else:
            return adminLogoutSession()

    except Exception as ex:
        print(ex)
Ejemplo n.º 4
0
def adminSendOTP():
    try:
        loginDAO = LoginDAO()
        loginVO = LoginVO()

        loginUsername = request.form["loginUsername"]
        loginVOList = loginDAO.findUser(loginUsername)
        print(loginVOList)
        loginDictList = [i.as_dict() for i in loginVOList]

        print(loginDictList)
        lenLoginDictList = len(loginDictList)
        if lenLoginDictList == 0:
            msg = "Username not found"

            return render_template('user/forgotPassword.html', error=msg)
        else:

            otp = ''.join((random.choice(string.digits)) for x in range(4))
            print(otp)

            sender = "*****@*****.**"

            receiver = loginUsername

            msg = MIMEMultipart()

            msg['From'] = sender

            msg['To'] = receiver

            msg['Subject'] = "OTP"

            msg.attach(MIMEText('Your OTP is:' + otp, 'plain'))

            session['session_OTP'] = otp
            session['session_loginUsername'] = loginUsername
            session['session_loginId'] = loginDictList[0]['loginId']

            server = smtplib.SMTP('smtp.gmail.com', 587)

            server.starttls()

            server.login(sender, "Qwer123@")

            text = msg.as_string()

            server.sendmail(sender, receiver, text)
            print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")
            return render_template('user/otp.html')
    except Exception as ex:
        print(ex)
Ejemplo n.º 5
0
def loadProfile():
    try:
        if session['loginRole'] == 'user':
            loginVO = LoginVO()
            loginDAO = LoginDAO()
            loginVO.loginId = session['loginId']
            getdataDict = loginDAO.getdata(loginVO)
            return render_template('user/profilePage.html',
                                   getdataDict=getdataDict)
        else:
            return render_template('admin/login.html')
    except:
        return render_template('admin/login.html')
Ejemplo n.º 6
0
def userFavouriteProperties():

    if session['loginRole'] != 'user':
        return redirect(url_for('login'))

    loginDAO = LoginDAO()
    loginVO = LoginVO()

    loginVO.loginId = session['loginId']
    loginDict = loginDAO.searchLoginDetailsById(loginVO)

    return render_template('user/favourite-properties.html',
                           loginDict=loginDict)
Ejemplo n.º 7
0
def adminLoadUsername():
    username = request.form['username']
    session['session_Username'] = username
    loginVO = LoginVO()
    loginDAO = LoginDAO()

    loginVO.loginUsername = username
    loginVOList = loginDAO.checkUsername(loginVO)
    if len(loginVOList) == 1:
        session['session_LoginId'] = loginVOList[0].loginId
        return redirect(url_for('adminloadOTP'))
    else:
        return render_template('admin/addForgetPassword.html', msg='Invalid Username')
Ejemplo n.º 8
0
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")
Ejemplo n.º 9
0
def usernewPassword():
    try:
        userOTP = request.form['userOtp']
        if userOTP == session['session_OTP']:
            loginVO = LoginVO()
            loginDAO = LoginDAO()

            loginPassword = ''.join(
                (random.choice(string.ascii_letters + string.digits))
                for x in range(8))

            print("loginPassword= "******"dkppwd1998@")

            text = msg.as_string()

            server.sendmail(sender, receiver, text)

            loginVO.loginUsername = receiver
            loginVO.loginId = session['session_loginId']
            loginVO.loginPassword = loginPassword

            loginDAO.updatePassword(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)
Ejemplo n.º 10
0
def adminSendForgotPassword():
    try:
        loginDAO = LoginDAO()
        loginVO = LoginVO()

        OTP = request.form["otp"]

        if session['session_OTP'] != OTP:
            msg = "OTP IS NOT MATCHED"

            return render_template('user/otp.html', error=msg)
        else:
            loginId = session['session_loginId']

            password = ''.join((random.choice(string.ascii_letters + string.digits)) for x in range(8))

            print(password)

            sender = "*****@*****.**"

            receiver = session['session_loginUsername']

            msg = MIMEMultipart()

            msg['From'] = sender

            msg['To'] = receiver

            msg['Subject'] = "YOUR PASSWORD"

            msg.attach(MIMEText('Your Password is:' + password, 'plain'))

            server = smtplib.SMTP('smtp.gmail.com', 587)

            server.starttls()

            server.login(sender, "Qwer123@")

            text = msg.as_string()

            server.sendmail(sender, receiver, text)
            print("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%")

            loginVO.loginId = loginId
            loginVO.loginPassword = password

            loginDAO.forgotPassword(loginVO)

            return render_template('user/login.html')
    except Exception as ex:
        print(ex)
Ejemplo n.º 11
0
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)
Ejemplo n.º 12
0
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 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)
Ejemplo n.º 14
0
def adminUserUnblock():
    try:
        if adminLoginSession() == 'admin':
            loginVO = LoginVO()
            loginDAO = LoginDAO()

            loginId = request.args.get('loginId')
            loginVO.loginId = loginId

            loginVO.loginStatus = 'active'
            loginDAO.userBlock(loginVO)

            return redirect(url_for('adminViewRegister'))
        else:
            return adminLogoutSession()
    except Exception as ex:
        print(ex)
def checkEmail():

    loginVO = LoginVO()
    loginDAO = LoginDAO()

    session['emailid'] = request.form['emailId']
    loginVO.loginEmailId = session['emailid']

    loginDict = loginDAO.searchLogin(loginVO)

    if len(loginDict) == 0:
        return render_template('admin/login.html',
                               loginemailIderror="Invalid EmailId")
    else:
        otpVo = OtpVO()
        otpDAO = OtpDAO()

        otpVo.otp = ''.join((random.choice(string.digits)) for x in range(4))
        otpVo.emailId = session['emailid']
        otpVo.otpActiveStatus = 'active'
        fromaddr = "*****@*****.**"
        toaddr = loginVO.loginEmailId

        msg = MIMEMultipart()

        msg['From'] = fromaddr

        msg['To'] = toaddr

        msg['Subject'] = "your OTP"

        msg.attach(MIMEText(otpVo.otp, '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()
        otpDAO.insertOtp(otpVo)
        return render_template('admin/getOTP.html')
Ejemplo n.º 16
0
def blockUser():

    try:
        if session['loginRole'] == 'admin':
            registerVO = RegisterVO()
            registerDAO = RegisterDAO()
            loginDAO = LoginDAO()
            loginVO = LoginVO()
            registerVO.register_LoginId = loginVO.loginId = request.args.get(
                'register_LoginId')
            registerVO.registerActiveStatus = loginVO.loginActiveStatus = 'deactive'
            registerDAO.blockUser(registerVO)
            loginDAO.blockUser(loginVO)
            return redirect(url_for('viewUser'))
        else:
            return render_template('admin/login.html')
    except:
        return render_template('admin/login.html')
Ejemplo n.º 17
0
def adminResetPassword():
    try:
        loginDAO = LoginDAO()
        loginVO = LoginVO()

        oldPassword = request.form["oldPassword"]
        newPassword = request.form["newPassword"]
        conformPassword = request.form["conformPassword"]

        loginUsername = session['session_loginUsername']

        loginVOList = loginDAO.findUser(loginUsername)
        print(loginVOList)
        loginDictList = [i.as_dict() for i in loginVOList]

        print(loginDictList)

        if loginDictList[0]['loginPassword'] != oldPassword:
            msg = "PASSWORD IS NOT MATCHED"

            return render_template('bloodbank/resetPassword.html', error=msg)
        else:
            if newPassword == conformPassword:
                loginId = session['session_loginId']

                loginVO.loginId = loginId
                loginVO.loginPassword = newPassword

                loginDAO.forgotPassword(loginVO)

                if adminLoginSession() == 'bloodbank':

                    return render_template('bloodbank/index.html')

                elif adminLoginSession() == 'user':

                    return render_template('user/index.html')
            else:
                msg = "NEWPASSWORD AND CONFORMPASSWORD IS NOT MATCHED"

                return render_template('bloodbank/resetPassword.html', error=msg)
    except Exception as ex:
        print(ex)
Ejemplo n.º 18
0
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()
Ejemplo n.º 19
0
def userProperties():
    if session['loginRole'] != 'user':
        return redirect(url_for('login'))

    loginDAO = LoginDAO()
    loginVO = LoginVO()

    propertyBasicDetailsDAO = PropertyBasicDetailsDAO()
    propertyBasicDetailsVO = PropertyBasicDetailsVO()

    loginVO.loginId = propertyBasicDetailsVO.property_LoginId = session[
        'loginId']
    loginDict = loginDAO.searchLoginDetailsById(loginVO)

    propertyDict = propertyBasicDetailsDAO.serachPropertyDetailsByLoginId(
        propertyBasicDetailsVO)

    return render_template('user/my-properties.html',
                           loginDict=loginDict,
                           propertyDict=propertyDict)
Ejemplo n.º 20
0
def loadEditprofile():
    try:
        if session['loginRole'] == 'user':
            loginVO = LoginVO()
            loginDAO = LoginDAO()
            loginVO.loginId = session['loginId']
            getdataDict = loginDAO.getdata(loginVO)
            if "error" in session:
                error = session['error']
                session.pop('error')
                return render_template('user/editProfile.html',
                                       getdataDict=getdataDict,
                                       error=error)
            else:
                return render_template('user/editProfile.html',
                                       getdataDict=getdataDict)
        else:
            return render_template('admin/login.html')
    except:
        return render_template('admin/login.html')
def adminUnblockUser():
    try:
        if adminLoginSession() == 'admin':
            loginDAO = LoginDAO()
            loginVO = LoginVO()

            loginId = request.args.get('loginId')
            loginStatus = 'active'

            loginVO.loginId = loginId
            loginVO.loginStatus = loginStatus

            loginDAO.UnblockUser(loginVO)

            return adminViewUser()

        else:
            return adminLogoutSession()

    except Exception as ex:
        print(ex)
Ejemplo n.º 22
0
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)
Ejemplo n.º 23
0
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)
Ejemplo n.º 24
0
def adminInsertNewPassword():
    try:
        loginDAO = LoginDAO()
        loginVO = LoginVO()
        loginPassword = request.form["loginPassword"]

        sender = "*****@*****.**"

        receiver = session["session_loginUsername"]

        msg = MIMEMultipart()

        msg['From'] = sender

        msg['To'] = receiver

        msg['Subject'] = "New Password"

        msg.attach(MIMEText(loginPassword, 'plain'))

        server = smtplib.SMTP('smtp.gmail.com', 587)

        server.starttls()

        server.login(sender, "keval12345")

        text = msg.as_string()

        server.sendmail(sender, receiver, text)

        server.quit()

        loginVO.loginId = session['session_loginId']
        loginVO.loginPassword = loginPassword
        loginDAO.loginUpdateUser(loginVO)
        return render_template("admin/login.html")

    except Exception as ex:
        print(ex)
Ejemplo n.º 25
0
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)
Ejemplo n.º 26
0
def updatePassword():
    try:
        if session['loginRole'] == 'user':
            loginDAO = LoginDAO()
            loginVO = LoginVO()

            loginVO.loginId = session['loginId']
            loginpassword = request.form['loginpassword']
            loginVO.loginPassword = request.form['loginPassword']

            loginDict = loginDAO.searchLoginIddata(loginVO)
            # print loginDict

            if loginpassword == loginDict[0]['loginPassword']:
                loginDAO.changePassword(loginVO)
                return redirect(url_for('loadProfile'))
            else:
                session['error'] = "*wrong password Please enter again"
                return redirect(url_for('loadChangepassword'))
        else:
            return render_template('admin/login.html')
    except:
        return render_template('admin/login.html')
Ejemplo n.º 27
0
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)
Ejemplo n.º 28
0
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 adminDeleteTrafficPoliceStation():
    try:
        if adminLoginSession() == 'admin':
            trafficPoliceStationId = request.args.get('trafficPoliceStationId')
            trafficPoliceStation_LoginId = request.args.get(
                'trafficPoliceStation_LoginId')

            trafficPoliceStationVO = TrafficPoliceStationVO()
            trafficPoliceStationDAO = TrafficPoliceStationDAO()
            loginVO = LoginVO()
            loginDAO = LoginDAO()

            trafficPoliceStationVO.trafficPoliceStationId = trafficPoliceStationId
            loginVO.loginId = trafficPoliceStation_LoginId

            trafficPoliceStationDAO.deleteTrafficPoliceStation(
                trafficPoliceStationVO)
            loginDAO.deleteLogin(loginVO)
            return redirect(url_for('adminViewTrafficPoliceStation'))
        else:
            adminLogoutSession()

    except Exception as ex:
        print(ex)
Ejemplo n.º 30
0
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)