changes to the upload of users process.

This commit is contained in:
2026-09-21 15:12:07 +02:00
parent b151dae3a8
commit a357881a20
3 changed files with 29 additions and 23 deletions
+19 -11
View File
@@ -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,
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({
+2 -3
View File
@@ -431,15 +431,14 @@ def check_password_strength(password):
if password is None:
return False
if len(password) < 12:
if len(password) < 5:
return False
has_lower = any(char.islower() for char in password)
has_upper = any(char.isupper() for char in password)
has_digit = any(char.isdigit() for char in password)
has_symbol = any(not char.isalnum() for char in password)
if not (has_lower and has_upper and has_digit and has_symbol):
if not (has_lower and has_upper and has_digit):
return False
return True
+3 -4
View File
@@ -88,11 +88,10 @@
<div class="password-rules" id="password-rules" aria-live="polite">
<p class="password-rules-title">Passwort-Anforderungen:</p>
<ul>
<li id="pw-rule-length" class="pw-rule">Mindestens 12 Zeichen</li>
<li id="pw-rule-length" class="pw-rule">Mindestens 5 Zeichen</li>
<li id="pw-rule-lower" class="pw-rule">Mindestens ein Kleinbuchstabe</li>
<li id="pw-rule-upper" class="pw-rule">Mindestens ein Grossbuchstabe</li>
<li id="pw-rule-digit" class="pw-rule">Mindestens eine Zahl</li>
<li id="pw-rule-symbol" class="pw-rule">Mindestens ein Sonderzeichen</li>
</ul>
</div>
@@ -105,7 +104,7 @@
name="password"
placeholder="Geben Sie ein sicheres Passwort ein"
required
pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9]).{12,}">
pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{5,}">
<button type="button" id="toggle-pw-btn" class="toggle-pw-btn" onclick="togglePasswordVisibility()" style="background:none; border:none; cursor:pointer; padding-right:10px;">👁️</button>
</div>
</div>
@@ -201,7 +200,7 @@ function generateUsername() {
// PASSWORT GENERATOR
function generateSecurePassword() {
const length = 12;
const length = 5;
const charsetLower = "abcdefghijklmnpqrstuvwxyz";
const charsetUpper = "ABCDEFGHIJKLMNPQRSTUVWXYZ";
const charsetNum = "123456789";