aboutsummaryrefslogtreecommitdiff
path: root/users
diff options
context:
space:
mode:
authorBobby <[email protected]>2023-05-28 00:41:28 -0400
committerBobby <[email protected]>2023-05-28 00:41:28 -0400
commit1bb0aa7433ec5f9d1bc6252204c8d6e8a682396c (patch)
tree38d17386300c1355418d5bed274f65045c8223ca /users
parentac5057a31021cf0c72fa9ad02d238fd0184f508e (diff)
downloadthatcomputerscientist-1bb0aa7433ec5f9d1bc6252204c8d6e8a682396c.tar.xz
thatcomputerscientist-1bb0aa7433ec5f9d1bc6252204c8d6e8a682396c.zip
Post show view count now, Django session uses redis cache
Diffstat (limited to 'users')
-rw-r--r--users/accountFunctions.py7
-rw-r--r--users/admin.py2
-rw-r--r--users/forms.py13
-rw-r--r--users/mail_send.py6
-rw-r--r--users/migrations/0001_initial.py2
-rw-r--r--users/migrations/0011_tokenstore.py2
-rw-r--r--users/models.py1
-rw-r--r--users/tokens.py3
-rw-r--r--users/urls.py3
-rw-r--r--users/views.py13
10 files changed, 34 insertions, 18 deletions
diff --git a/users/accountFunctions.py b/users/accountFunctions.py
index be60e29f..f5d77d72 100644
--- a/users/accountFunctions.py
+++ b/users/accountFunctions.py
@@ -1,8 +1,11 @@
-from users.models import TokenStore, UserProfile
-import uuid
import secrets
+import uuid
+
from django.utils import timezone
+from users.models import TokenStore, UserProfile
+
+
def generate_token():
uid = uuid.uuid4().hex
token = secrets.token_urlsafe(32)
diff --git a/users/admin.py b/users/admin.py
index 8d54136f..0f1d5fdb 100644
--- a/users/admin.py
+++ b/users/admin.py
@@ -1,7 +1,7 @@
from django.contrib import admin
# Register your models here.
-from .models import UserProfile, TokenStore
+from .models import TokenStore, UserProfile
admin.site.register(UserProfile)
admin.site.register(TokenStore)
diff --git a/users/forms.py b/users/forms.py
index 8ce104b1..e10da9f7 100644
--- a/users/forms.py
+++ b/users/forms.py
@@ -1,15 +1,20 @@
# Registration form
+import string
+from random import choice
+
from django import forms
from django.contrib.auth.models import User
-from users.models import UserProfile
from django.template.loader import render_to_string
from django.utils.html import strip_tags
+
+from blog.context_processors import avatar_list
+from users.models import UserProfile
+
from .accountFunctions import store_token
from .mail_send import send_email
-from random import choice
-from blog.context_processors import avatar_list
-import string
+
+
class RegisterForm(forms.Form):
username = forms.CharField(label='Username', max_length=30, min_length=4)
email = forms.EmailField(label='Email')
diff --git a/users/mail_send.py b/users/mail_send.py
index 742f84f5..be167eb1 100644
--- a/users/mail_send.py
+++ b/users/mail_send.py
@@ -1,10 +1,12 @@
# python script for sending SMTP configuration with Oracle Cloud Infrastructure Email Delivery
-import smtplib
import email.utils
-from email.message import EmailMessage
+import smtplib
import ssl
+from email.message import EmailMessage
+
from django.conf import settings
+
def send_email(sender, sender_name, recipient, subject, body_html, body_text):
# Replace [email protected] with your "From" address.
# This address must be verified.
diff --git a/users/migrations/0001_initial.py b/users/migrations/0001_initial.py
index fd66accf..a8a78c6b 100644
--- a/users/migrations/0001_initial.py
+++ b/users/migrations/0001_initial.py
@@ -1,8 +1,8 @@
# Generated by Django 4.0.6 on 2022-07-29 15:58
+import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
-import django.db.models.deletion
class Migration(migrations.Migration):
diff --git a/users/migrations/0011_tokenstore.py b/users/migrations/0011_tokenstore.py
index 78a5478b..f0bf9330 100644
--- a/users/migrations/0011_tokenstore.py
+++ b/users/migrations/0011_tokenstore.py
@@ -1,8 +1,8 @@
# Generated by Django 4.1.4 on 2023-04-30 03:19
+import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
-import django.db.models.deletion
class Migration(migrations.Migration):
diff --git a/users/models.py b/users/models.py
index 76dfc896..f11f2f46 100644
--- a/users/models.py
+++ b/users/models.py
@@ -1,6 +1,7 @@
from django.conf import settings
from django.db import models
+
# User Profile Model
class UserProfile(models.Model):
user = models.ForeignKey(
diff --git a/users/tokens.py b/users/tokens.py
index 1e481b3e..05d73362 100644
--- a/users/tokens.py
+++ b/users/tokens.py
@@ -1,8 +1,9 @@
import os
+
+from Crypto.Cipher import AES
from django.contrib.auth.tokens import PasswordResetTokenGenerator
from dotenv import load_dotenv
from six import text_type
-from Crypto.Cipher import AES
load_dotenv()
diff --git a/users/urls.py b/users/urls.py
index 9e900638..132049b6 100644
--- a/users/urls.py
+++ b/users/urls.py
@@ -1,6 +1,7 @@
+from django.contrib import admin
from django.urls import path
+
from . import views
-from django.contrib import admin
app_name = 'users'
urlpatterns = [
diff --git a/users/views.py b/users/views.py
index 3780d80f..209fb1cd 100644
--- a/users/views.py
+++ b/users/views.py
@@ -1,14 +1,17 @@
-from django.http import HttpResponseRedirect, HttpResponse
-from django.shortcuts import redirect, reverse
-from django.contrib.auth import authenticate, login, logout, update_session_auth_hash
from django.contrib import messages
-from .models import UserProfile
+from django.contrib.auth import (authenticate, login, logout,
+ update_session_auth_hash)
from django.contrib.auth.models import User
+from django.http import HttpResponse, HttpResponseRedirect
+from django.shortcuts import redirect, reverse
from django.template.loader import render_to_string
from django.utils.html import strip_tags
-from .forms import UpdateUserDetailsForm
+
from .accountFunctions import store_token, verify_token
+from .forms import UpdateUserDetailsForm
from .mail_send import send_email
+from .models import UserProfile
+
# Create your views here.
def login_user(request):