diff --git a/apps/common/utils/random.py b/apps/common/utils/random.py index 53143e4db..267de8d22 100644 --- a/apps/common/utils/random.py +++ b/apps/common/utils/random.py @@ -18,6 +18,7 @@ def random_ip(): def random_string(length: int, lower=True, upper=True, digit=True, special_char=False, symbols=string_punctuation): + random.seed() args_names = ['lower', 'upper', 'digit'] args_values = [lower, upper, digit] args_string = [string.ascii_lowercase, string.ascii_uppercase, string.digits] diff --git a/apps/users/models/user.py b/apps/users/models/user.py index 6852c2333..98facb346 100644 --- a/apps/users/models/user.py +++ b/apps/users/models/user.py @@ -3,8 +3,6 @@ # import base64 import datetime -import random -import string import uuid from typing import Callable @@ -607,8 +605,7 @@ class TokenMixin: return self.access_keys.first() def generate_reset_token(self): - letter = string.ascii_letters + string.digits - token = ''.join([random.choice(letter) for _ in range(50)]) + token = random_string(50) self.set_cache(token) return token