From 3b4e1634ab6bf0912c26c649fdd9645f81a26355 Mon Sep 17 00:00:00 2001
From: Chneemann
If you did not create an account with us, please disregard this email.
diff --git a/backend/videoflix/users/admin.py b/backend/videoflix/users/admin.py index c13af5a..12ef327 100644 --- a/backend/videoflix/users/admin.py +++ b/backend/videoflix/users/admin.py @@ -13,9 +13,7 @@ class CustomUserAdmin(UserAdmin): 'Individual data', { 'fields': ( - 'custom', - 'phone', - 'address', + 'verify_email', ) } ) diff --git a/backend/videoflix/users/models.py b/backend/videoflix/users/models.py index fa9f6da..5378cdc 100644 --- a/backend/videoflix/users/models.py +++ b/backend/videoflix/users/models.py @@ -1,7 +1,17 @@ -from django.contrib.auth.models import AbstractUser +import secrets +import string from django.db import models +from django.contrib.auth.models import AbstractUser class CustomUser(AbstractUser): - custom = models.CharField(max_length=1000, blank=True) - phone = models.CharField(max_length=20, blank=True) - address = models.CharField(max_length=150, blank=True) \ No newline at end of file + verify_email = models.CharField(max_length=15, blank=True) + + def save(self, *args, **kwargs): + if not self.verify_email: + self.verify_email = self.generate_verification_token() + super().save(*args, **kwargs) + + @staticmethod + def generate_verification_token(length=15): + characters = string.ascii_letters + string.digits + return ''.join(secrets.choice(characters) for _ in range(length)) diff --git a/backend/videoflix/videoflix/urls.py b/backend/videoflix/videoflix/urls.py index 6b18d44..9fe4ad8 100644 --- a/backend/videoflix/videoflix/urls.py +++ b/backend/videoflix/videoflix/urls.py @@ -17,7 +17,7 @@ Including another URLconf from django.contrib import admin from django.urls import path, include from users import views -from auth.views import LoginView, RegisterView +from auth.views import LoginView, RegisterView, VerifyEmailView urlpatterns = [ path('admin/', admin.site.urls), @@ -25,4 +25,6 @@ urlpatterns = [ path('users/