-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from kkkkkkkkatya/manage
add send emails feature
- Loading branch information
Showing
10 changed files
with
65 additions
and
3 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,10 +93,10 @@ | |
|
||
AUTHENTICATION_BACKENDS = [ | ||
# Needed to login by username in Django admin, regardless of `allauth` | ||
'django.contrib.auth.backends.ModelBackend', | ||
#'django.contrib.auth.backends.ModelBackend', | ||
|
||
# `allauth` specific authentication methods, such as login by email | ||
#'allauth.account.auth_backends.AuthenticationBackend', | ||
'allauth.account.auth_backends.AuthenticationBackend', | ||
|
||
] | ||
|
||
|
@@ -169,3 +169,11 @@ | |
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field | ||
|
||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' | ||
|
||
|
||
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' | ||
EMAIL_HOST = 'smtp.gmail.com' | ||
EMAIL_PORT = 587 | ||
EMAIL_USE_TLS = True | ||
EMAIL_HOST_USER = '[email protected]' | ||
EMAIL_HOST_PASSWORD = 'bjtsvjnnmjypxmrb' |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django.db.models.signals import post_save | ||
from django.dispatch import receiver | ||
from django.contrib.auth.models import User | ||
from django.contrib.auth.signals import user_logged_in | ||
from .views import welcome_email | ||
|
||
|
||
# Signal receiver for post_save | ||
@receiver(post_save, sender=User) | ||
def check_new_user(sender, instance, created, **kwargs): | ||
if created: | ||
instance._newly_created = True | ||
print(f"_newly_created attribute for user {instance.username}: {instance._newly_created}") | ||
elif not hasattr(instance, '_newly_created'): | ||
instance._newly_created = False | ||
|
||
|
||
@receiver(user_logged_in) | ||
def send_welcome_email_if_new(sender, request, user, **kwargs): | ||
if (getattr(user, '_newly_created')): | ||
#and request.user.backend == 'allauth.account.auth_backends.AuthenticationBackend'): | ||
welcome_email(request) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters