def register(): email = request.form.get('email') name = request.form.get('name') password = request.form.get('passw') prénom = request.form.get('prénom') if(email is not None): try: if(validMail(email)): if(len(password) < 8): return render_template("register.html", error="Password too short please make sure it is at least 8 characters") else: tk = setToken(email=encode(email, 11)) ud = setUserData(email=encode(email, 12), login=encode( password, 12), passwords=init()) cd = setClientData(email=encode(email, 13), nom=encode(name, 13), prénom=encode(prénom, 13), sex='H', balance='0.0', incomes='0.0', expenses='0.0') return render_template("signin.html", wrongpassword="") else: return render_template("register.html", error="entrez un mail valide ! ") except: return render_template("register.html", error="votre mail existe deja") return render_template("register.html", error="")
def account(): tkn = request.form["token"] if not session.get('userMail') is None: z = getClientData(encode(session['userMail'], 13)) user_tkn = str(int(getTokenUser(encode(session['userMail'], 11)))) print("user token = "+user_tkn) if tkn == user_tkn: ChangeTokenUser(encode(session['userMail'], 11)) return render_template("MainPage.html", name=decode(z[0], 13), firstname=decode(z[1], 13), balance=z[2], Incomes=z[3], Expenses=z[4]) else: return render_template("token.html", error='error : wrong token!') else: return redirect('/signin')
def sendMail(sendTo, subject, message): email = '*****@*****.**' password = '******' msg = MIMEMultipart() msg['From'] = email msg['To'] = sendTo msg['Subject'] = subject msg.attach(MIMEText(message, 'html')) # the image is in the current directory x = str(TokenGenerator.getTokenUser(encode(sendTo, 11))) fp = open(create_image_captcha(x), 'rb') msgImage = MIMEImage(fp.read()) fp.close() # Define the image's ID as referenced above msgImage.add_header('Content-ID', '<token>') msg.attach(msgImage) server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login(email, password) text = msg.as_string() server.sendmail(email, sendTo, text) server.quit()
def token(): f = open("message.html", "r") ms = f.read() f.close() mail = request.form["email"] z = getClientData(encode(request.form["email"], 13)) ms = str.replace(ms, "name", decode(z[0], 13)) print(ms) print("coded mail : "+mail) print("coded mail : "+encode(mail, 11)) print("coded mail : "+encode(mail, 12)) print("coded mail : "+encode(mail, 13)) session['userMail'] = mail password = request.form["passw"] print("password entred is : " + password) print("password is : "+decode(str(getUserPassword(encode(mail, 12), init())), 12)) if(password == decode(str(getUserPassword(encode(mail, 12), init())), 12)): sendMail(mail, "Bank Token", ms) return render_template("token.html", error='') return render_template("signin.html", wrongpassword='******')
def register(): email = request.form.get('email') name = request.form.get('name') password = request.form.get('passw') prénom = request.form.get('prénom') sexe=request.form.get('sexe') print(email) if(email is not None): if(getUserPassword(decode(email, 12), init()) == ''): if(validMail(email)): tk = setToken(email=encode(email, 11)) ud = setUserData(email=encode(email, 12), login=encode( password, 12), passwords=init()) cd = setClientData(email=encode(email, 13), nom=encode(name, 13), prénom=encode(prénom, 13), sex=sexe, balance='0.0', incomes='0.0', expenses='0.0') return render_template("signin.html", wrongpassword="") else: return render_template("register.html", error="entrez un mail valide ! ") else: return render_template("register.html", error="votre mail existe deja") return render_template("register.html", error="")