Fix: Remove problematic characters from temp password generation

- Remove special characters (!@#$%^&*) that cause login issues
- Remove ambiguous characters (I, O, l, i, o, 0, 1) for better readability
- Keep only alphanumeric characters for safe copy-paste and input

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
richardtekula
2025-12-05 11:27:06 +01:00
parent 176d3c5fec
commit 4f4f53cbdc

View File

@@ -23,15 +23,15 @@ export const comparePassword = async (password, hash) => {
/** /**
* Generuje náhodné dočasné heslo * Generuje náhodné dočasné heslo
* Používa len bezpečné znaky (bez problematických ako #, $, %, &, atď.)
* @param {number} length - Dĺžka hesla (default: 12) * @param {number} length - Dĺžka hesla (default: 12)
* @returns {string} Náhodné heslo * @returns {string} Náhodné heslo
*/ */
export const generateTempPassword = (length = 12) => { export const generateTempPassword = (length = 12) => {
const uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; const uppercase = 'ABCDEFGHJKLMNPQRSTUVWXYZ'; // bez I, O (ľahko zameniteľné)
const lowercase = 'abcdefghijklmnopqrstuvwxyz'; const lowercase = 'abcdefghjkmnpqrstuvwxyz'; // bez i, l, o (ľahko zameniteľné)
const numbers = '0123456789'; const numbers = '23456789'; // bez 0, 1 (ľahko zameniteľné)
const special = '!@#$%^&*'; const all = uppercase + lowercase + numbers;
const all = uppercase + lowercase + numbers + special;
let password = ''; let password = '';
@@ -39,7 +39,6 @@ export const generateTempPassword = (length = 12) => {
password += uppercase[Math.floor(Math.random() * uppercase.length)]; password += uppercase[Math.floor(Math.random() * uppercase.length)];
password += lowercase[Math.floor(Math.random() * lowercase.length)]; password += lowercase[Math.floor(Math.random() * lowercase.length)];
password += numbers[Math.floor(Math.random() * numbers.length)]; password += numbers[Math.floor(Math.random() * numbers.length)];
password += special[Math.floor(Math.random() * special.length)];
// Zvyšok náhodne // Zvyšok náhodne
for (let i = password.length; i < length; i++) { for (let i = password.length; i < length; i++) {