aboutsummaryrefslogtreecommitdiff
path: root/users/tokens.py
diff options
context:
space:
mode:
authorBobby <[email protected]>2023-01-08 12:55:38 -0500
committerBobby <[email protected]>2023-01-08 12:55:38 -0500
commit8d270d0da154d8a863401581e742de7a0eb191ed (patch)
treec76494aca226a11bd9329bb87fb87abf7eb85cdd /users/tokens.py
parent732b43800422e2a6d9c2c4d3de9d20be8b628127 (diff)
downloadthatcomputerscientist-8d270d0da154d8a863401581e742de7a0eb191ed.tar.xz
thatcomputerscientist-8d270d0da154d8a863401581e742de7a0eb191ed.zip
Add account actions working
Diffstat (limited to 'users/tokens.py')
-rw-r--r--users/tokens.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/users/tokens.py b/users/tokens.py
index 77bd4e88..1e481b3e 100644
--- a/users/tokens.py
+++ b/users/tokens.py
@@ -1,4 +1,3 @@
-import cryptocode
import os
from django.contrib.auth.tokens import PasswordResetTokenGenerator
from dotenv import load_dotenv
@@ -17,11 +16,17 @@ class AccountActivationTokenGenerator(PasswordResetTokenGenerator):
class EmailChangeTokenGenerator():
def encrypt(self, email):
auth_string = os.getenv('AUTHORIZATION_STRING')
- return cryptocode.encrypt(email, auth_string)
+ key = auth_string.encode('utf-8')[0:16]
+ cipher = AES.new(key, AES.MODE_CFB, key)
+ return cipher.encrypt(email.encode('utf-8')).hex()
+
def decrypt(self, token):
auth_string = os.getenv('AUTHORIZATION_STRING')
- return cryptocode.decrypt(token, auth_string)
+ key = auth_string.encode('utf-8')[0:16]
+ cipher = AES.new(key, AES.MODE_CFB, key)
+ return cipher.decrypt(bytes.fromhex(token)).decode('utf-8')
+
class CaptchaTokenGenerator():
def encrypt(self, captcha_string):