From c36dc582ae031e7ea7bfb12142c5f0f768a98168 Mon Sep 17 00:00:00 2001 From: Israel Figueroa Date: Tue, 30 Jul 2024 13:14:45 -0400 Subject: [PATCH] fix --- .env.develop | 4 +--- .env.testing | 4 +--- project/api/views/auth.py | 14 +++++--------- project/project/settings.py | 9 ++++++--- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/.env.develop b/.env.develop index 33bf0bd..223082d 100644 --- a/.env.develop +++ b/.env.develop @@ -20,8 +20,6 @@ DB_MONGO_PASS=password SMTP_HOST=smtp-mail.outlook.com SMTP_PORT=587 SMTP_PROTOCOL=tls -SMTP_USER=francisco.sandoval@outlook.cl -SMTP_PASS=aigdvnrbueitklry SMTP_FROM='"Sistema Transporte" ' # PATH UPLOAD @@ -33,4 +31,4 @@ URL_PARADERO='http://localhost:3001/rutaParadero/?id=' #COORDENADAS DE INICIO PARA EL MAPA COORDINI_LAT=-36.8270 -COORDINI_LNG=-73.0503 \ No newline at end of file +COORDINI_LNG=-73.0503 diff --git a/.env.testing b/.env.testing index 93c9d7c..75e97d6 100644 --- a/.env.testing +++ b/.env.testing @@ -14,10 +14,8 @@ DB_REDIS_PORT=6379 SMTP_HOST=smtp-mail.outlook.com SMTP_PORT=587 SMTP_PROTOCOL=tls -SMTP_USER=francisco.sandoval@outlook.cl -SMTP_PASS=aigdvnrbueitklry SMTP_FROM='"Sistema Transporte" ' # PATH UPLOAD GTFS_UPLOADS=/uploads/gtfs -PHOTOS_UPLOADS=/uploads/photos \ No newline at end of file +PHOTOS_UPLOADS=/uploads/photos diff --git a/project/api/views/auth.py b/project/api/views/auth.py index 89f93eb..aff3572 100755 --- a/project/api/views/auth.py +++ b/project/api/views/auth.py @@ -32,12 +32,12 @@ def jwt_login(request): if rut != '0': dv = rut[-1].upper() rut = rut[:-1] - + usuario = None if rut == '0' and password == '0': usuario = { 'login': '0', 'clave': '0' } - + # solo se permite usuario 0 si no existen usuarios vigentes count = models.Usuario.objects.filter(vigente = True).count() if count > 0: @@ -158,25 +158,21 @@ def nueva_contrasena(request): return HttpResponse('error al cambiar contraseña', status = 500) - - def enviar_correo(destinatario, asunto, contenido): try: template = get_template('correo_recuperar.html') # Ruta al template del correo 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.send() return True 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) return False - - def http_referer(request): if 'HTTP_REFERER' in request.META: referer = request.META['HTTP_REFERER'] @@ -185,4 +181,4 @@ def http_referer(request): host = request.META['HTTP_HOST'] port = request.META['SERVER_PORT'] referer = f'{protocol}://{host}' - return referer \ No newline at end of file + return referer diff --git a/project/project/settings.py b/project/project/settings.py index 5b11456..3a9ac7e 100644 --- a/project/project/settings.py +++ b/project/project/settings.py @@ -182,6 +182,9 @@ LOGGING = { EMAIL_HOST = config('SMTP_HOST') EMAIL_PORT = config('SMTP_PORT', 587) -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') == 'tls' \ No newline at end of file +EMAIL_SENDER = config('SMTP_FROM') + + +#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'