mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-16 10:26:16 +00:00
changes in task list API and add special character in password for added junior
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
"""Account utils"""
|
||||
from celery import shared_task
|
||||
|
||||
import random
|
||||
"""Import django"""
|
||||
from django.conf import settings
|
||||
from rest_framework import viewsets, status
|
||||
@ -289,3 +289,27 @@ def get_user_full_name(user_obj):
|
||||
to get user's full name
|
||||
"""
|
||||
return f"{user_obj.first_name} {user_obj.last_name}" if user_obj.first_name or user_obj.last_name else "User"
|
||||
|
||||
def make_special_password(length=10):
|
||||
# Define character sets
|
||||
lowercase_letters = string.ascii_lowercase
|
||||
uppercase_letters = string.ascii_uppercase
|
||||
digits = string.digits
|
||||
special_characters = '!@#$%^&*()_-+=<>?/[]{}|'
|
||||
|
||||
# Combine character sets
|
||||
all_characters = lowercase_letters + uppercase_letters + digits + special_characters
|
||||
|
||||
# Create a password with random characters
|
||||
password = (
|
||||
random.choice(lowercase_letters) +
|
||||
random.choice(uppercase_letters) +
|
||||
random.choice(digits) +
|
||||
random.choice(special_characters) +
|
||||
''.join(random.choice(all_characters) for _ in range(length - 4))
|
||||
)
|
||||
|
||||
# Shuffle the characters to make it more random
|
||||
password_list = list(password)
|
||||
random.shuffle(password_list)
|
||||
return ''.join(password_list)
|
||||
|
Reference in New Issue
Block a user