Send re-authentication notification emails
This commit is contained in:
parent
101058672b
commit
f02a7b6eb7
4 changed files with 42 additions and 1 deletions
|
|
@ -193,7 +193,8 @@ STATICFILES_FINDERS = [
|
||||||
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
|
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
|
||||||
]
|
]
|
||||||
|
|
||||||
DEFAULT_FROM_EMAIL = "newsreader@rss.fudiggity.nl"
|
# Email
|
||||||
|
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"
|
||||||
|
|
||||||
# Project settings
|
# Project settings
|
||||||
VERSION = get_current_version()
|
VERSION = get_current_version()
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,19 @@ TEMPLATES = [
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Email
|
||||||
|
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
|
||||||
|
DEFAULT_FROM_EMAIL = os.environ.get("EMAIL_DEFAULT_FROM", "webmaster@localhost")
|
||||||
|
|
||||||
|
EMAIL_HOST = os.environ.get("EMAIL_HOST", "localhost")
|
||||||
|
EMAIL_PORT = os.environ.get("EMAIL_PORT", 25)
|
||||||
|
|
||||||
|
EMAIL_HOST_USER = os.environ.get("EMAIL_HOST_USER", "")
|
||||||
|
EMAIL_HOST_PASSWORD = os.environ.get("EMAIL_HOST_PASSWORD", "")
|
||||||
|
|
||||||
|
EMAIL_USE_TLS = os.environ.get("EMAIL_USE_TLS", False)
|
||||||
|
EMAIL_USE_SSL = os.environ.get("EMAIL_USE_SSL", False)
|
||||||
|
|
||||||
# Reddit integration
|
# Reddit integration
|
||||||
REDDIT_CLIENT_ID = os.environ.get("REDDIT_CLIENT_ID", "")
|
REDDIT_CLIENT_ID = os.environ.get("REDDIT_CLIENT_ID", "")
|
||||||
REDDIT_CLIENT_SECRET = os.environ.get("REDDIT_CLIENT_SECRET", "")
|
REDDIT_CLIENT_SECRET = os.environ.get("REDDIT_CLIENT_SECRET", "")
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
|
from django.core.mail import send_mail
|
||||||
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
@ -106,6 +108,16 @@ class RedditTokenTask(app.Task):
|
||||||
|
|
||||||
user.reddit_refresh_token = None
|
user.reddit_refresh_token = None
|
||||||
user.save()
|
user.save()
|
||||||
|
|
||||||
|
message = _(
|
||||||
|
"Your Reddit account credentials have expired. Re-authenticate in"
|
||||||
|
" the settings page to keep retrieving Reddit specific information"
|
||||||
|
" from your account."
|
||||||
|
)
|
||||||
|
|
||||||
|
send_mail(
|
||||||
|
"Reddit account needs re-authentication", message, None, [user.email]
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
response_data = response.json()
|
response_data = response.json()
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,10 @@ from datetime import datetime
|
||||||
from json import JSONDecodeError
|
from json import JSONDecodeError
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.core.mail import send_mail
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.html import format_html, urlize
|
from django.utils.html import format_html, urlize
|
||||||
|
from django.utils.translation import ugettext as _
|
||||||
|
|
||||||
import pytz
|
import pytz
|
||||||
|
|
||||||
|
|
@ -240,6 +242,19 @@ class TwitterClient(PostClient):
|
||||||
stream.rule.user.twitter_oauth_token_secret = None
|
stream.rule.user.twitter_oauth_token_secret = None
|
||||||
stream.rule.user.save()
|
stream.rule.user.save()
|
||||||
|
|
||||||
|
message = _(
|
||||||
|
"Your Twitter account credentials have expired. Re-authenticate in"
|
||||||
|
" the settings page to keep retrieving Twitter specific information"
|
||||||
|
" from your account."
|
||||||
|
)
|
||||||
|
|
||||||
|
send_mail(
|
||||||
|
"Twitter account needs re-authentication",
|
||||||
|
message,
|
||||||
|
None,
|
||||||
|
[stream.rule.user.email],
|
||||||
|
)
|
||||||
|
|
||||||
self.set_rule_error(stream.rule, e)
|
self.set_rule_error(stream.rule, e)
|
||||||
|
|
||||||
break
|
break
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue