diff options
| author | Bobby <[email protected]> | 2023-07-19 20:11:39 -0400 |
|---|---|---|
| committer | Bobby <[email protected]> | 2023-07-19 20:11:39 -0400 |
| commit | de926f958c794b09455a1e6a1d04e8fb0cd61c40 (patch) | |
| tree | 6e7f4c875634ceed5fc543c70100fb419b68326e | |
| parent | cd4e4001c74f4c52d9066f39a06339a59a3cf085 (diff) | |
| download | thatcomputerscientist-de926f958c794b09455a1e6a1d04e8fb0cd61c40.tar.xz thatcomputerscientist-de926f958c794b09455a1e6a1d04e8fb0cd61c40.zip | |
Inactive User Deletion + General Config Changes
| -rw-r--r-- | requirements.txt | 1 | ||||
| -rw-r--r-- | solitude/frontend/public/index.html | 2 | ||||
| -rw-r--r-- | templates/@solitude_frontend/index.html | 2 | ||||
| -rw-r--r-- | templates/blog/register.html | 1 | ||||
| -rw-r--r-- | templates/blog/site_policy.html | 2 | ||||
| -rw-r--r-- | thatcomputerscientist/settings.py | 2 | ||||
| -rw-r--r-- | thatcomputerscientist/tasks.py | 24 | ||||
| -rw-r--r-- | thatcomputerscientist/urls.py | 3 | ||||
| -rw-r--r-- | users/apps.py | 5 |
9 files changed, 36 insertions, 6 deletions
diff --git a/requirements.txt b/requirements.txt index 91505927..236ff635 100644 --- a/requirements.txt +++ b/requirements.txt @@ -26,3 +26,4 @@ scikit-learn akismet google-cloud-translate django-hosts +apscheduler diff --git a/solitude/frontend/public/index.html b/solitude/frontend/public/index.html index da7db4a6..69f7d27f 100644 --- a/solitude/frontend/public/index.html +++ b/solitude/frontend/public/index.html @@ -4,7 +4,7 @@ <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width,initial-scale=1.0"> - <link rel="icon" href="../../../static/images/favicons/favicon-32x32.png"> + <link rel="icon" href="/static/images/favicons/favicon-32x32.png"> <title><%= htmlWebpackPlugin.options.title %></title> </head> <body> diff --git a/templates/@solitude_frontend/index.html b/templates/@solitude_frontend/index.html index a5b6bad4..02386298 100644 --- a/templates/@solitude_frontend/index.html +++ b/templates/@solitude_frontend/index.html @@ -1 +1 @@ -<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="../../../static/images/favicons/favicon-32x32.png"><title>frontend</title><script defer="defer" src="/../../static/%40solitude/prod/js/chunk-vendors.adef8d7f.js"></script><script defer="defer" src="/../../static/%40solitude/prod/js/app.c59158b4.js"></script><link href="/../../static/%40solitude/prod/css/app.f4c9be56.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but frontend doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
\ No newline at end of file +<!doctype html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/static/images/favicons/favicon-32x32.png"><title>frontend</title><script defer="defer" src="/../../static/%40solitude/prod/js/chunk-vendors.adef8d7f.js"></script><script defer="defer" src="/../../static/%40solitude/prod/js/app.c59158b4.js"></script><link href="/../../static/%40solitude/prod/css/app.f4c9be56.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but frontend doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
\ No newline at end of file diff --git a/templates/blog/register.html b/templates/blog/register.html index ce72d35a..ec470cb3 100644 --- a/templates/blog/register.html +++ b/templates/blog/register.html @@ -13,6 +13,7 @@ </form> <br><br> <p>By registering on this site, you agree to everything that's <a href="{% url 'blog:policy' %}">written here</a>.</p> +<p><b>Note</b>: Upon registering, you will be sent an email with a link to activate your account. If you don't activate your account within 72 hours, your username will be released and you will have to register again.</p> {% for message in messages %} {% if 'accountCreated' in message.tags %} <p><small class="success">{{ message.message }}</small></p> diff --git a/templates/blog/site_policy.html b/templates/blog/site_policy.html index bc17d2a6..d03a81dc 100644 --- a/templates/blog/site_policy.html +++ b/templates/blog/site_policy.html @@ -62,7 +62,7 @@ <li><b>Length Restrictions:</b> 4-30 characters, alphanumeric only. (Unchanged)</li> <li><b>Protected Usernames:</b> Certain usernames like <i>admin</i>, <i>administrator</i>, <i>root</i>, <i>moderator</i>, etc. (non-exhaustive list) are protected and cannot be used for registering an account. (New)</li> <li><b>Changing Username:</b> Right now, this site does not allow username changes. (Unchanged) There are plans to allow username changes in the future, but it will be limited to once every 30 days. (New)</li> -<li><b>Username Purging:</b> Accounts which have registered and haven't verified their email within 72 hours will be purged and the username will be available for registration again. (New) (Not yet implemented)</li> +<li><b>Username Purging:</b> Accounts which have registered and haven't verified their email within 72 hours will be purged and the username will be available for registration again. (New) <s>(Not yet implemented)</s> <i>Implemented</i>; as of Jul 19, 2023.</li> </ul> diff --git a/thatcomputerscientist/settings.py b/thatcomputerscientist/settings.py index 7b6289d2..ddae61f3 100644 --- a/thatcomputerscientist/settings.py +++ b/thatcomputerscientist/settings.py @@ -38,8 +38,8 @@ DEBUG = True if os.getenv('ENVIRONMENT') == 'development' else False ALLOWED_HOSTS = ["*"] CSRF_TRUSTED_ORIGINS = ['https://*.thatcomputerscientist.com', 'http://*.thatcomputerscientist.com', 'https://*.shi.foo'] -SESSION_COOKIE_DOMAIN = None DOMAIN_NAME = "shi.foo" +SESSION_COOKIE_DOMAIN = ".domain.internal" if os.getenv('ENVIRONMENT') == 'development' else ".shi.foo" SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') ROOT_HOSTCONF = 'thatcomputerscientist.hosts' ROOT_URLCONF = 'thatcomputerscientist.urls' diff --git a/thatcomputerscientist/tasks.py b/thatcomputerscientist/tasks.py new file mode 100644 index 00000000..a41b3cee --- /dev/null +++ b/thatcomputerscientist/tasks.py @@ -0,0 +1,24 @@ +from users.models import UserProfile +from django.contrib.auth.models import User +from django.utils import timezone +from datetime import datetime +from apscheduler.schedulers.background import BackgroundScheduler + +def delete_inactive_users(): + # Delete users who have not verified their email address within 72 hours + # of registering, ie. email_verified=False and date_joined > 72 hours ago + + users = UserProfile.objects.filter(email_verified=False) + for user in users: + try: + current_user = User.objects.get(user=user) + if current_user.date_joined < timezone.now() - timezone.timedelta(hours=72): + current_user.delete() + except: + pass + + +def schedule(): + scheduler = BackgroundScheduler() + scheduler.add_job(delete_inactive_users, 'interval', hours=1) + scheduler.start() diff --git a/thatcomputerscientist/urls.py b/thatcomputerscientist/urls.py index a2d9cdfd..34a4f76d 100644 --- a/thatcomputerscientist/urls.py +++ b/thatcomputerscientist/urls.py @@ -18,7 +18,6 @@ from django.conf.urls.static import static from django.contrib import admin from django.contrib.sitemaps.views import sitemap from django.urls import include, path -from haystack.views import search_view_factory from .sitemaps import (CategorySitemap, GithubSitemap, PostSitemap, StaticViewSitemap, TagSitemap) @@ -34,12 +33,12 @@ sitemaps = { handler404 = 'thatcomputerscientist.error_handler.custom_404' urlpatterns = [ - path('admin', admin.site.urls), path('', include('blog.urls', namespace='blog')), path('users', include('users.urls', namespace='users')), path('blog-admin', include('blog_admin.urls', namespace='blog-admin')), path('repositories', include(('dev_status.urls', 'dev_status'), namespace='dev_status')), path('ignis', include(('ignis.urls', 'ignis'), namespace='ignis')), + path('admin/', admin.site.urls), path('sitemap.xml', sitemap, {'sitemaps': sitemaps}, name='django.contrib.sitemaps.views.sitemap'), ] diff --git a/users/apps.py b/users/apps.py index 72b14010..16ed36b8 100644 --- a/users/apps.py +++ b/users/apps.py @@ -4,3 +4,8 @@ from django.apps import AppConfig class UsersConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'users' + + def ready(self): + + from thatcomputerscientist.tasks import schedule + schedule() |
