Browse Source

password generation: added "complexity" to the generated password by including more character classes

master
Vašek Šraier 4 years ago
parent
commit
4bc3477f8f
  1. 14
      register.py

14
register.py

@ -23,8 +23,16 @@ HOST = config.HOST
ADMIN_TOKEN = config.ADMIN_TOKEN ADMIN_TOKEN = config.ADMIN_TOKEN
def rand_str(n) -> str: def rand_password(n: int) -> str:
return ''.join([random.choice(string.ascii_lowercase) for _ in range(n)]) """
Vraci string, ktery splnuje pozadavky Gitey na slozitost hesel a pri tom je dostatecne nahodny.
@param n Delka nahodne casti retezce
"""
req_compliance_str = 'Aa1!@'
rnd_str = ''.join([random.choice(string.ascii_letters) for _ in range(n)])
return req_compliance_str + rnd_str
def text_red(text) -> str: def text_red(text) -> str:
@ -190,7 +198,7 @@ def register(username: str, seminar: str, fullname: str, email: str, host, admin
# pripravime si uzivatele na zalozeni # pripravime si uzivatele na zalozeni
create_user_req = CreateUserOption(email=email, full_name=fullname, username=username, create_user_req = CreateUserOption(email=email, full_name=fullname, username=username,
password=rand_str(20)) password=rand_password(20))
# provedeme zmeny v systemu # provedeme zmeny v systemu
user = checked_api_action(lambda: admin_api.admin_create_user(body=create_user_req), "Zakladam noveho uzivatele...") user = checked_api_action(lambda: admin_api.admin_create_user(body=create_user_req), "Zakladam noveho uzivatele...")

Loading…
Cancel
Save