mirror of https://github.com/jumpserver/jumpserver
fix: 修复 random error
parent
6c9c64a55f
commit
4009457000
|
@ -1,10 +1,9 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
import struct
|
|
||||||
import random
|
import random
|
||||||
import socket
|
import socket
|
||||||
import string
|
import string
|
||||||
|
import struct
|
||||||
|
|
||||||
string_punctuation = '!#$%&()*+,-.:;<=>?@[]^_~'
|
string_punctuation = '!#$%&()*+,-.:;<=>?@[]^_~'
|
||||||
|
|
||||||
|
@ -19,6 +18,7 @@ def random_ip():
|
||||||
|
|
||||||
|
|
||||||
def random_string(length: int, lower=True, upper=True, digit=True, special_char=False):
|
def random_string(length: int, lower=True, upper=True, digit=True, special_char=False):
|
||||||
|
random.seed(None)
|
||||||
args_names = ['lower', 'upper', 'digit', 'special_char']
|
args_names = ['lower', 'upper', 'digit', 'special_char']
|
||||||
args_values = [lower, upper, digit, special_char]
|
args_values = [lower, upper, digit, special_char]
|
||||||
args_string = [string.ascii_lowercase, string.ascii_uppercase, string.digits, string_punctuation]
|
args_string = [string.ascii_lowercase, string.ascii_uppercase, string.digits, string_punctuation]
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
#
|
#
|
||||||
import base64
|
import base64
|
||||||
import datetime
|
import datetime
|
||||||
import random
|
|
||||||
import string
|
|
||||||
import uuid
|
import uuid
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
|
@ -562,8 +560,7 @@ class TokenMixin:
|
||||||
return self.access_keys.first()
|
return self.access_keys.first()
|
||||||
|
|
||||||
def generate_reset_token(self):
|
def generate_reset_token(self):
|
||||||
letter = string.ascii_letters + string.digits
|
token = random_string(50)
|
||||||
token = ''.join([random.choice(letter) for _ in range(50)])
|
|
||||||
self.set_cache(token)
|
self.set_cache(token)
|
||||||
return token
|
return token
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue