-
Notifications
You must be signed in to change notification settings - Fork 18
Custom from email #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
Passwordless Authentication for Django with Magic Links. | ||
|
||
This package was created with a focus on [ease of setup](#steps-to-impliment), [security](#security) and testing (coverage is currently at 100%). The idea is to use sane defaults to quickly create secure single-use token authentication for Django. | ||
This package was created with a focus on [ease of setup](#configuration), [security](#security) and testing (coverage is currently at 100%). The idea is to use sane defaults to quickly create secure single-use token authentication for Django. | ||
|
||
 | ||
|
||
|
@@ -185,7 +185,7 @@ When overriding this template please ensure the following content is included: | |
<p>Already have an account? <a href='{% url 'magiclink:login' %}'>Log in here</a></p> | ||
``` | ||
|
||
There are several forms made avalible in the context on this page depending on what information you want to collect: | ||
There are several forms made available in the context on this page depending on what information you want to collect: | ||
* **SignupFormEmailOnly** - Only includes an `email` field | ||
* **SignupForm** - Includes `name` and `email` fields | ||
* **SignupFormWithUsername** - Includes `username` and `email` fields | ||
|
@@ -319,8 +319,12 @@ MAGICLINK_ANTISPAM_FIELD_TIME = 1 | |
MAGICLINK_LOGIN_VERIFY_URL = 'magiclink:login_verify' | ||
|
||
# If an email address has been added to the unsubscribe table but is also | ||
# assocaited with a Django user, should a login email be sent | ||
# associated with a Django user, should a login email be sent | ||
MAGICLINK_IGNORE_UNSUBSCRIBE_IF_USER = False | ||
|
||
# By default, the sign in e-mail is sent from the DEFAULT_FROM_EMAIL. set | ||
# this if you would like to override the from e-mail. | ||
MAGICLINK_FROM_EMAIL = '[email protected]' | ||
``` | ||
|
||
## Magic Link cleanup | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -119,4 +119,6 @@ | |||||
|
||||||
IGNORE_UNSUBSCRIBE_IF_USER = getattr(settings, 'MAGICLINK_IGNORE_UNSUBSCRIBE_IF_USER', False) | ||||||
if not isinstance(IGNORE_UNSUBSCRIBE_IF_USER, bool): | ||||||
raise ImproperlyConfigured('"MAGICLINK_IGNORE_UNSUBSCRIBE_IF_USER" must be a boolean') | ||||||
raise ImproperlyConfigured('"MAGICLINK_IGNORE_UNSUBSCRIBE_IF_USER" must be a boolean') | ||||||
|
||||||
FROM_EMAIL = getattr(settings, 'MAGICLINK_FROM_SETTINGS', settings.DEFAULT_FROM_EMAIL) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there is a typo here which will cause this functionality not to work. A test will fail with:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It could also be good to validate this and default back if it's not valid. Something like (untested):
Then please include a test to check the email gets defaulted back to |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,3 +61,5 @@ | |
LOGOUT_REDIRECT_URL = 'no_login' | ||
MAGICLINK_LOGIN_SENT_REDIRECT = 'magiclink:login_sent' | ||
MAGICLINK_SIGNUP_LOGIN_REDIRECT = 'no_login' | ||
|
||
DEFAULT_FROM_EMAIL = '[email protected]' |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -371,3 +371,16 @@ def test_ignore_unsubscribe_if_user_bad_value(settings): | |
with pytest.raises(ImproperlyConfigured): | ||
from magiclink import settings | ||
reload(settings) | ||
|
||
|
||
def test_from_settings(settings): | ||
settings.MAGICLINK_FROM_EMAIL = '[email protected]' | ||
from magiclink import settings as mlsettings | ||
reload(mlsettings) | ||
assert mlsettings.FROM_EMAIL == settings.MAGICLINK_FROM_EMAIL | ||
|
||
|
||
def test_default_email_if_no_magiclink_email(settings): | ||
from magiclink import settings as mlsettings | ||
reload(mlsettings) | ||
assert mlsettings.FROM_EMAIL == '[email protected]' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a new test to actually check this value is used?
Something like the
test_send_email_pass_email_in_unsubscribe
test intest_models.py
without the unsubscribe bits - https://github.com/pyepye/django-magiclink/blob/master/tests/test_models.py#L114-L135There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the djsettings import at the top is now no longer used, can you remove it please?