Fixes in sendmail tls and passwordfield, now keyutils have a better function for get random strings
This commit is contained in:
parent
d68587f752
commit
96c2690f1c
3 changed files with 16 additions and 7 deletions
|
|
@ -16,4 +16,4 @@ def create_key(n=10):
|
|||
|
||||
rand_bytes=urandom(n)
|
||||
|
||||
return b64encode(rand_bytes).decode('utf-8')
|
||||
return b64encode(rand_bytes).decode('utf-8')[0:-2]
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ from email.mime.base import MIMEBase
|
|||
from email.mime.image import MIMEImage
|
||||
from email.mime.multipart import MIMEMultipart
|
||||
from email.mime.text import MIMEText
|
||||
import ssl as ssl_module
|
||||
import sys
|
||||
|
||||
class SendMail:
|
||||
|
||||
|
|
@ -22,6 +24,12 @@ class SendMail:
|
|||
|
||||
ssl=True
|
||||
|
||||
if sys.version_info < (3, 6):
|
||||
|
||||
context = ssl_module.SSLContext(ssl_module.PROTOCOL_TLSv1_2)
|
||||
else:
|
||||
context = ssl_module.SSLContext(ssl_module.PROTOCOL_TLS)
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.smtp=smtplib.SMTP(host=self.host, port=self.port)
|
||||
|
|
@ -33,7 +41,7 @@ class SendMail:
|
|||
|
||||
try:
|
||||
|
||||
self.smtp.starttls()
|
||||
self.smtp.starttls(context=self.context)
|
||||
|
||||
except smtplib.SMTPHeloError:
|
||||
|
||||
|
|
@ -79,9 +87,9 @@ class SendMail:
|
|||
|
||||
return False
|
||||
|
||||
except smtplib.SMTPException:
|
||||
|
||||
self.txt_error='Error: any method for login is avaliable'
|
||||
except smtplib.SMTPException as e:
|
||||
# self.txt_error=e.__str__()
|
||||
self.txt_error='Error: any method for login is avaliable - '+e.__str__()
|
||||
|
||||
return False
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ try:
|
|||
|
||||
#if crypt.METHOD_SHA512 in crypt.methods:
|
||||
|
||||
value = bcrypt_sha256.encrypt(value)
|
||||
#value = bcrypt_sha256.encrypt(value)
|
||||
value = bcrypt_sha256.hash(value)
|
||||
|
||||
"""
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue