Skip to content

Commit

Permalink
Updated email code and removed old auth route
Browse files Browse the repository at this point in the history
  • Loading branch information
caparker committed Jun 6, 2024
1 parent ff4ab3b commit d39bcca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions openaq_api/openaq_api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
UnprocessableEntityLog,
WarnLog,
)
from openaq_api.routers.auth import router as auth_router
#from openaq_api.routers.auth import router as auth_router
from openaq_api.routers.averages import router as averages_router
from openaq_api.routers.cities import router as cities_router
from openaq_api.routers.countries import router as countries_router
Expand Down Expand Up @@ -254,7 +254,7 @@ def favico():
app.include_router(providers.router)
app.include_router(sensors.router)

app.include_router(auth_router)
# app.include_router(auth_router)
app.include_router(averages_router)
app.include_router(cities_router)
app.include_router(countries_router)
Expand Down
14 changes: 7 additions & 7 deletions openaq_api/openaq_api/v3/routers/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ def send_email(destination_email: str, msg: EmailMessage):
else:
return send_ses_email(destination_email, msg)

def send_smpt_email(destination_email: str, msg: EmailMessage):
with smtplib.SMTP(settings.SMTP_EMAIL_HOST, 587) as s:
def send_smtp_email(destination_email: str, msg: EmailMessage):
with smtplib.SMTP_SSL(settings.SMTP_EMAIL_HOST, 465) as s:
s.starttls()
s.login(settings.SMTP_EMAIL_USER, settings.SMTP_EMAIL_PASSWORD)
return server.sendmail(settings.EMAIL_SENDER, destination_email, msg.as_string())
return s.send_message(msg)


def send_ses_email(destination_email: str, msg: EmailMessage):
Expand Down Expand Up @@ -75,7 +75,7 @@ def send_change_password_email(full_name: str, email: str):
msg["Subject"] = "OpenAQ Explorer - Password changed"
msg["From"] = settings.EMAIL_SENDER
msg["To"] = email
response = send_smtp_email(email, msg)
response = send_email(email, msg)
logger.info(
SESEmailLog(
detail=json.dumps(
Expand Down Expand Up @@ -119,7 +119,7 @@ def send_verification_email(verification_code: str, full_name: str, email: str):
msg["Subject"] = "OpenAQ Explorer - Verify your email"
msg["From"] = settings.EMAIL_SENDER
msg["To"] = email
response = send_smtp_email(email, msg)
response = send_email(email, msg)
logger.info(
SESEmailLog(
detail=json.dumps(
Expand Down Expand Up @@ -163,7 +163,7 @@ def send_password_reset_email(verification_code: str, email: str):
msg["Subject"] = "OpenAQ Explorer - Reset password request"
msg["From"] = settings.EMAIL_SENDER
msg["To"] = email
response = send_smtp_email(email, msg)
response = send_email(email, msg)
logger.info(
SESEmailLog(
detail=json.dumps(
Expand Down Expand Up @@ -207,7 +207,7 @@ def send_password_changed_email(email: str):
msg["Subject"] = "OpenAQ Explorer - Reset password success"
msg["From"] = settings.EMAIL_SENDER
msg["To"] = email
response = send_smtp_email(email, msg)
response = send_email(email, msg)

logger.info(
SESEmailLog(
Expand Down

0 comments on commit d39bcca

Please sign in to comment.