master
ifiguero 2024-07-30 13:14:45 -04:00
parent fb7429ed4d
commit c36dc582ae
4 changed files with 13 additions and 18 deletions

View File

@ -20,8 +20,6 @@ DB_MONGO_PASS=password
SMTP_HOST=smtp-mail.outlook.com SMTP_HOST=smtp-mail.outlook.com
SMTP_PORT=587 SMTP_PORT=587
SMTP_PROTOCOL=tls SMTP_PROTOCOL=tls
SMTP_USER=francisco.sandoval@outlook.cl
SMTP_PASS=aigdvnrbueitklry
SMTP_FROM='"Sistema Transporte" <francisco.sandoval@outlook.cl>' SMTP_FROM='"Sistema Transporte" <francisco.sandoval@outlook.cl>'
# PATH UPLOAD # PATH UPLOAD
@ -33,4 +31,4 @@ URL_PARADERO='http://localhost:3001/rutaParadero/?id='
#COORDENADAS DE INICIO PARA EL MAPA #COORDENADAS DE INICIO PARA EL MAPA
COORDINI_LAT=-36.8270 COORDINI_LAT=-36.8270
COORDINI_LNG=-73.0503 COORDINI_LNG=-73.0503

View File

@ -14,10 +14,8 @@ DB_REDIS_PORT=6379
SMTP_HOST=smtp-mail.outlook.com SMTP_HOST=smtp-mail.outlook.com
SMTP_PORT=587 SMTP_PORT=587
SMTP_PROTOCOL=tls SMTP_PROTOCOL=tls
SMTP_USER=francisco.sandoval@outlook.cl
SMTP_PASS=aigdvnrbueitklry
SMTP_FROM='"Sistema Transporte" <francisco.sandoval@outlook.cl>' SMTP_FROM='"Sistema Transporte" <francisco.sandoval@outlook.cl>'
# PATH UPLOAD # PATH UPLOAD
GTFS_UPLOADS=/uploads/gtfs GTFS_UPLOADS=/uploads/gtfs
PHOTOS_UPLOADS=/uploads/photos PHOTOS_UPLOADS=/uploads/photos

View File

@ -32,12 +32,12 @@ def jwt_login(request):
if rut != '0': if rut != '0':
dv = rut[-1].upper() dv = rut[-1].upper()
rut = rut[:-1] rut = rut[:-1]
usuario = None usuario = None
if rut == '0' and password == '0': if rut == '0' and password == '0':
usuario = { 'login': '0', 'clave': '0' } usuario = { 'login': '0', 'clave': '0' }
# solo se permite usuario 0 si no existen usuarios vigentes # solo se permite usuario 0 si no existen usuarios vigentes
count = models.Usuario.objects.filter(vigente = True).count() count = models.Usuario.objects.filter(vigente = True).count()
if count > 0: if count > 0:
@ -158,25 +158,21 @@ def nueva_contrasena(request):
return HttpResponse('error al cambiar contraseña', status = 500) return HttpResponse('error al cambiar contraseña', status = 500)
def enviar_correo(destinatario, asunto, contenido): def enviar_correo(destinatario, asunto, contenido):
try: try:
template = get_template('correo_recuperar.html') # Ruta al template del correo template = get_template('correo_recuperar.html') # Ruta al template del correo
contenido_renderizado = template.render(contenido) contenido_renderizado = template.render(contenido)
mensaje = EmailMultiAlternatives(asunto, '', settings.EMAIL_HOST_USER, [destinatario]) mensaje = EmailMultiAlternatives(asunto, contenido, settings.EMAIL_SENDER, [destinatario])
mensaje.attach_alternative(contenido_renderizado, 'text/html') mensaje.attach_alternative(contenido_renderizado, 'text/html')
mensaje.send() mensaje.send()
return True return True
except Exception as e: except Exception as e:
print(f'EMAIL_HOST: {EMAIL_HOST}', flush=True) print(f'EMAIL_HOST: {settings.EMAIL_HOST}', flush=True)
print(f'ERROR: {e}', flush=True) print(f'ERROR: {e}', flush=True)
return False return False
def http_referer(request): def http_referer(request):
if 'HTTP_REFERER' in request.META: if 'HTTP_REFERER' in request.META:
referer = request.META['HTTP_REFERER'] referer = request.META['HTTP_REFERER']
@ -185,4 +181,4 @@ def http_referer(request):
host = request.META['HTTP_HOST'] host = request.META['HTTP_HOST']
port = request.META['SERVER_PORT'] port = request.META['SERVER_PORT']
referer = f'{protocol}://{host}' referer = f'{protocol}://{host}'
return referer return referer

View File

@ -182,6 +182,9 @@ LOGGING = {
EMAIL_HOST = config('SMTP_HOST') EMAIL_HOST = config('SMTP_HOST')
EMAIL_PORT = config('SMTP_PORT', 587) EMAIL_PORT = config('SMTP_PORT', 587)
EMAIL_HOST_USER = config('SMTP_USER', 'tu_correo@gmail.com') # Tu dirección de correo EMAIL_SENDER = config('SMTP_FROM')
EMAIL_HOST_PASSWORD = config('SMTP_PASS', 'tu_contraseña') # Tu contraseña de correo
EMAIL_USE_TLS = config('SMTP_PROTOCOL') == 'tls'
#EMAIL_HOST_USER = config('SMTP_USER', 'tu_correo@gmail.com') # Tu dirección de correo
#EMAIL_HOST_PASSWORD = config('SMTP_PASS', 'tu_contraseña') # Tu contraseña de correo
EMAIL_USE_TLS = config('SMTP_PROTOCOL') == 'plain'