Open claudep opened 2 years ago
There is also an import from phonedevice plugin in views.core
:
Which breaks when importing anything from views
package if phonenumbers
is not installed:
File ".virtualenvs/lib/python3.9/site-packages/two_factor/views/__init__.py", line 1, in <module>
from .core import (
File ".virtualenvs/lib/python3.9/site-packages/two_factor/views/core.py", line 38, in <module>
from two_factor.plugins.phonenumber.utils import get_available_phone_methods
File ".virtualenvs/lib/python3.9/site-packages/two_factor/plugins/phonenumber/utils.py", line 3, in <module>
import phonenumbers
ModuleNotFoundError: No module named 'phonenumbers'
Sure, probably get_available_phone_methods
should be moved (back?) in two_factor.utils
?
Sure, probably
get_available_phone_methods
should be moved (back?) intwo_factor.utils
?
Since that method does not rely on other code in the phonenumber plugin it could work.
But IMO it would be better to find a way to have the SetupCompleteView
to get extra context using the registry.
Also, now that I was looking for that method (and other imports from that plugin), there is an import from phone plugin also in two_factor.views.profile
(which is also imported in __init__
file):
To have a nice plugin system also the ProfileView
should get its data from the registry. Otherwive there it would just be hardcoded and not plugin-based.
Please feel free to suggest a PR with your ideas!
Hello,
may I link this SO thread without necessarily opening a new issue as it may be related?
The above SO thread should be fixed by 2ff98b514d42db97d7c9fdabe2face86fc6f8188
@claudep I don't know about the current situation of this issue, Is there anything that I can help with?
@peymanslh, I hope @sevdog will continue working on this and suggest a patch.
If I will work on this I would like to do a quite heavy rework to have a real plugin-based app, where every OTP method is not mandatory (while currently TOTP and Static are not threated as such). This will require some time and may lead to a long PR.
In commit 07dac39d35783, we laid the foundation for a new plugin architecture, and the PhoneNumber capability was moved to a plugin. However, there are still places in the main code that expect the phone plugin to be activated.
This is some meta issue to make the phonenumber plugin really optional.