コード例 #1
0
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, "9925646618")

            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.adminUpdateUser(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)
コード例 #2
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)
コード例 #3
0
def adminUnblockUser():
    try:
        if adminLoginSession() == 'admin':
            loginDAO = LoginDAO()
            loginVO = LoginVO()

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

            loginVO.loginId = loginId
            loginVO.loginStatus = loginStatus

            loginDAO.adminUpdateUser(loginVO)

            return redirect(url_for('adminViewUser'))
        else:
            return adminLogoutSession()
    except Exception as ex:
        print(ex)
コード例 #4
0
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']
            registerGender = request.form['registerGender']
            registerAddress = request.form['registerAddress']
            registerContactNumber = request.form['registerContactNumber']

            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, "9925646618")

                text = msg.as_string()

                server.sendmail(sender, receiver, text)

                server.quit()

                loginVO.loginUsername = loginUsername
                loginVO.loginPassword = loginPassword

                loginDAO.adminUpdateUser(loginVO)

            registerVO.registerId = registerId
            registerVO.registerFirstname = registerFirstname
            registerVO.registerLastname = registerLastname
            registerVO.registerGender = registerGender
            registerVO.registerAddress = registerAddress
            registerVO.registerContactNumber = registerContactNumber

            registerDAO.updateRegister(registerVO)

            return redirect(url_for('userLoadDashboard'))
        else:
            return adminLogoutSession()
    except Exception as ex:
        print(ex)