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
|
lowers = string.ascii_lowercase
|
||||||
uppers = string.ascii_uppercase
|
uppers = string.ascii_uppercase
|
||||||
digits = string.digits
|
digits = string.digits
|
||||||
symbols = "!@#$%^&*()_+~|}{[]:;?><,.-="
|
|
||||||
|
|
||||||
# Ensure at least one character from each required category
|
# Ensure at least one character from each required category
|
||||||
pwd = [
|
pwd = [
|
||||||
secrets.choice(lowers),
|
secrets.choice(lowers),
|
||||||
secrets.choice(uppers),
|
secrets.choice(uppers),
|
||||||
secrets.choice(digits),
|
secrets.choice(digits)
|
||||||
secrets.choice(symbols)
|
|
||||||
]
|
]
|
||||||
all_chars = lowers + uppers + digits + symbols
|
all_chars = lowers + uppers + digits
|
||||||
pwd += [secrets.choice(all_chars) for _ in range(length - 4)]
|
pwd += [secrets.choice(all_chars) for _ in range(length - 4)]
|
||||||
|
|
||||||
# Shuffle so guaranteed types aren't always at the start
|
# Shuffle so guaranteed types aren't always at the start
|
||||||
@@ -8666,19 +8664,29 @@ def register_csv():
|
|||||||
|
|
||||||
# Benutzernamen & Passwort generieren
|
# Benutzernamen & Passwort generieren
|
||||||
username = us.build_unique_username_from_name(name, last_name)
|
username = us.build_unique_username_from_name(name, last_name)
|
||||||
password = generate_compliant_password(16)
|
password = generate_compliant_password(5)
|
||||||
|
|
||||||
# In DB speichern
|
action_permissions = None
|
||||||
success = us.add_user(
|
page_permissions = None
|
||||||
username=username,
|
|
||||||
password=password,
|
try:
|
||||||
name=name,
|
us.add_user(
|
||||||
last_name=last_name,
|
username,
|
||||||
is_student=False,
|
password,
|
||||||
student_card_id=None,
|
name,
|
||||||
max_borrow_days=None,
|
last_name,
|
||||||
permission_preset=permission_preset,
|
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:
|
if success:
|
||||||
created_users.append({
|
created_users.append({
|
||||||
|
|||||||
@@ -431,15 +431,14 @@ def check_password_strength(password):
|
|||||||
if password is None:
|
if password is None:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if len(password) < 12:
|
if len(password) < 5:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
has_lower = any(char.islower() for char in password)
|
has_lower = any(char.islower() for char in password)
|
||||||
has_upper = any(char.isupper() for char in password)
|
has_upper = any(char.isupper() for char in password)
|
||||||
has_digit = any(char.isdigit() 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 False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@@ -88,11 +88,10 @@
|
|||||||
<div class="password-rules" id="password-rules" aria-live="polite">
|
<div class="password-rules" id="password-rules" aria-live="polite">
|
||||||
<p class="password-rules-title">Passwort-Anforderungen:</p>
|
<p class="password-rules-title">Passwort-Anforderungen:</p>
|
||||||
<ul>
|
<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-lower" class="pw-rule">Mindestens ein Kleinbuchstabe</li>
|
||||||
<li id="pw-rule-upper" class="pw-rule">Mindestens ein Grossbuchstabe</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-digit" class="pw-rule">Mindestens eine Zahl</li>
|
||||||
<li id="pw-rule-symbol" class="pw-rule">Mindestens ein Sonderzeichen</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -105,7 +104,7 @@
|
|||||||
name="password"
|
name="password"
|
||||||
placeholder="Geben Sie ein sicheres Passwort ein"
|
placeholder="Geben Sie ein sicheres Passwort ein"
|
||||||
required
|
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>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
@@ -201,7 +200,7 @@ function generateUsername() {
|
|||||||
|
|
||||||
// PASSWORT GENERATOR
|
// PASSWORT GENERATOR
|
||||||
function generateSecurePassword() {
|
function generateSecurePassword() {
|
||||||
const length = 12;
|
const length = 5;
|
||||||
const charsetLower = "abcdefghijklmnpqrstuvwxyz";
|
const charsetLower = "abcdefghijklmnpqrstuvwxyz";
|
||||||
const charsetUpper = "ABCDEFGHIJKLMNPQRSTUVWXYZ";
|
const charsetUpper = "ABCDEFGHIJKLMNPQRSTUVWXYZ";
|
||||||
const charsetNum = "123456789";
|
const charsetNum = "123456789";
|
||||||
|
|||||||
Reference in New Issue
Block a user