perf: 优化系统用户生成密码的复杂度 (#5648)

* perf: 优化系统用户生成密码的复杂度

* perf: 修改 common.random_string

Co-authored-by: ibuler <ibuler@qq.com>
Co-authored-by: Bai <bugatti_it@163.com>
This commit is contained in:
fit2bot
2021-03-01 18:40:07 +08:00
committed by GitHub
parent 1036d1c132
commit 6f3ead3c42
5 changed files with 37 additions and 14 deletions

View File

@@ -18,7 +18,7 @@ from django.shortcuts import reverse
from orgs.utils import current_org
from orgs.models import OrganizationMember, Organization
from common.utils import date_expired_default, get_logger, lazyproperty
from common.utils import date_expired_default, get_logger, lazyproperty, random_string
from common import fields
from common.const import choices
from common.db.models import ChoiceSet
@@ -387,7 +387,7 @@ class TokenMixin:
cache_key = '%s_%s' % (self.id, remote_addr)
token = cache.get(cache_key)
if not token:
token = uuid.uuid4().hex
token = random_string(36)
cache.set(token, self.id, expiration)
cache.set('%s_%s' % (self.id, remote_addr), token, expiration)
date_expired = timezone.now() + timezone.timedelta(seconds=expiration)