From 29aec214e00bbf6bcb199f6d2b474fcbfcca0ed4 Mon Sep 17 00:00:00 2001 From: xiaomaoxue <1131274737@qq.com> Date: Wed, 18 Apr 2018 14:05:09 +0800 Subject: [PATCH] =?UTF-8?q?[bugfix]=20=E5=A2=9E=E5=8A=A0LDAP=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + apps/common/utils.py | 2 +- apps/users/forms.py | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 051862a..34fae97 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ apps/__pycache__/ apps/static/ionicons/ *.pyc data/* +config.py \ No newline at end of file diff --git a/apps/common/utils.py b/apps/common/utils.py index 292ca71..f909ae0 100644 --- a/apps/common/utils.py +++ b/apps/common/utils.py @@ -382,7 +382,7 @@ def close(self): self.file_obj.close() -def generate_activation_code(len=20, n=200): +def generate_activation_code(len=20, n=20): '''生成n个长度为len的随机序列码''' random.seed() chars = string.ascii_letters + string.digits diff --git a/apps/users/forms.py b/apps/users/forms.py index 8ed4884..ae9173e 100644 --- a/apps/users/forms.py +++ b/apps/users/forms.py @@ -163,7 +163,7 @@ def save(self, commit=True): if password: password = password else: - password = generate_activation_code() + password = generate_activation_code(n=1)[0] status = ldap_tool.ldap_add_user(cn, mail, username, password) if status: msg = "ldap用户创建成功"