Пример #1
0
def insertRegister():
    registerDAO=RegisterDAO()
    registerVO=RegisterVO()
    loginDAO=LoginDAO()
    loginVO=LoginVO()
    registerVO.registerOrganizationname=request.form['registerOrganizatonname']
    registerVO.registerContact=request.form['registerContact']
    registerVO.registerCategory=request.form['registerCategory']
    registerVO.registerAddress=request.form['registerAddress']
    registerVO.register_LoginId = str(loginDAO.searchLoginId(loginVO)[0].values()[0])
    loginVO.loginEmail = request.form['registerEmail']
    loginVO.loginPassword = ''.join((random.choice(string.ascii_letters + string.digits)) for x in range(8))
    loginVO.loginRole='user'
    print(loginVO.loginEmail)
    loginDict = loginDAO.searchLogin(loginVO)
    if len(loginDict) == 0:
        print("registerPassword="******"*****@*****.**"
        toaddr = loginVO.loginEmail
        msg = MIMEMultipart()
        msg['From'] = fromaddr
        msg['To'] = toaddr
        msg['Subject'] = "PYTHON PASSWORD"
        msg.attach(MIMEText(loginVO.loginPassword, 'plain'))
        server = smtplib.SMTP('smtp.gmail.com', 587)
        server.starttls()
        server.login(fromaddr, "BHAIbhai4725")
        text = msg.as_string()
        server.sendmail(fromaddr, toaddr, text)
        server.quit()
        loginDAO.insertLogin(loginVO)

        registerDAO.insertRegister(registerVO)
        return redirect(url_for('loadLogin'))
    else:
        flash('Email already exist !', 'danger')
        return redirect(url_for('loadRegister'))
Пример #2
0
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'))