Skip to content

Commit

Permalink
raises ImproperlyConfigured when trying to verify phone number and no…
Browse files Browse the repository at this point in the history
… PHONE_VERIFICATION_BACKEND was specified
  • Loading branch information
smirolo committed Aug 1, 2024
1 parent 88670b3 commit 98299fe
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions signup/backends/phone_verification/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2023, Djaodjin Inc.
# Copyright (c) 2024, Djaodjin Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand All @@ -24,6 +24,7 @@
import logging

from django.contrib.auth import REDIRECT_FIELD_NAME
from django.core.exceptions import ImproperlyConfigured
from django.utils import translation

from ... import settings, signals
Expand All @@ -43,8 +44,14 @@ def send_verification_phone(contact, request,
workflow once verification is completed.
"""
#pylint:disable=unused-argument
backend = load_backend(settings.PHONE_VERIFICATION_BACKEND)
phone = str(contact.phone) # insures we pass a string to the backend.
if not settings.PHONE_VERIFICATION_BACKEND:
LOGGER.error("Attempting to verify phone number '%s',"\
" yet no PHONE_VERIFICATION_BACKEND was specified.", phone)
raise ImproperlyConfigured("Attempting to verify phone number '%s',"\
" yet no PHONE_VERIFICATION_BACKEND was specified." % phone)

backend = load_backend(settings.PHONE_VERIFICATION_BACKEND)
with translation.override(contact.lang):
backend.send(phone, contact.phone_code)

Expand Down

0 comments on commit 98299fe

Please sign in to comment.