changes to the upload of users process.
This commit is contained in:
+24
-16
@@ -8533,16 +8533,14 @@ def generate_compliant_password(length=16):
|
||||
lowers = string.ascii_lowercase
|
||||
uppers = string.ascii_uppercase
|
||||
digits = string.digits
|
||||
symbols = "!@#$%^&*()_+~|}{[]:;?><,.-="
|
||||
|
||||
# Ensure at least one character from each required category
|
||||
pwd = [
|
||||
secrets.choice(lowers),
|
||||
secrets.choice(uppers),
|
||||
secrets.choice(digits),
|
||||
secrets.choice(symbols)
|
||||
secrets.choice(digits)
|
||||
]
|
||||
all_chars = lowers + uppers + digits + symbols
|
||||
all_chars = lowers + uppers + digits
|
||||
pwd += [secrets.choice(all_chars) for _ in range(length - 4)]
|
||||
|
||||
# Shuffle so guaranteed types aren't always at the start
|
||||
@@ -8666,19 +8664,29 @@ def register_csv():
|
||||
|
||||
# Benutzernamen & Passwort generieren
|
||||
username = us.build_unique_username_from_name(name, last_name)
|
||||
password = generate_compliant_password(16)
|
||||
password = generate_compliant_password(5)
|
||||
|
||||
# In DB speichern
|
||||
success = us.add_user(
|
||||
username=username,
|
||||
password=password,
|
||||
name=name,
|
||||
last_name=last_name,
|
||||
is_student=False,
|
||||
student_card_id=None,
|
||||
max_borrow_days=None,
|
||||
permission_preset=permission_preset,
|
||||
)
|
||||
action_permissions = None
|
||||
page_permissions = None
|
||||
|
||||
try:
|
||||
us.add_user(
|
||||
username,
|
||||
password,
|
||||
name,
|
||||
last_name,
|
||||
is_student=False,
|
||||
student_card_id=None,
|
||||
max_borrow_days=None,
|
||||
permission_preset=permission_preset,
|
||||
action_permissions=action_permissions,
|
||||
page_permissions=page_permissions,
|
||||
)
|
||||
success = True
|
||||
except Exception as e:
|
||||
app.logger.error(f"Fehler beim Erstellen des Benutzers {username}: {e}")
|
||||
success = False
|
||||
continue
|
||||
|
||||
if success:
|
||||
created_users.append({
|
||||
|
||||
Reference in New Issue
Block a user