Skip to content

Commit c9ee8f1

Browse files
committed
Corrección de las contraseñas
1 parent 4a4ad27 commit c9ee8f1

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

web/index.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ <h3 className="text-lg font-bold text-white">{title || "EduBot Forest Studio"}</
529529
const isValidName = (name) => /^[a-zA-ZáéíóúÁÉÍÓÚñÑ\s]+$/.test(name);
530530
const isValidTeacherUser = (user) => /^(?=.*[a-zA-Z])[a-zA-Z0-9._-]{3,15}$/.test(user);
531531
const isValidStudentUser = (user) => /^(?=.*[a-zA-Z])[a-zA-Z0-9]{3,8}$/.test(user);
532-
const isValidPassword = (pwd) => pwd.length >= 7;
532+
const isValidPassword = (pwd) => pwd.length >= 8;
533533

534534
const handleRoleSelect = (role) => {
535535
setViewState(role === 'student' ? 'login_student' : 'login_teacher');
@@ -581,7 +581,7 @@ <h3 className="text-lg font-bold text-white">{title || "EduBot Forest Studio"}</
581581
return;
582582
}
583583
if (!isValidPassword(inputPwd)) {
584-
setError("La contraseña debe tener al menos 7 caracteres.");
584+
setError("La contraseña debe tener al menos 8 caracteres.");
585585
return;
586586
}
587587

@@ -616,7 +616,7 @@ <h3 className="text-lg font-bold text-white">{title || "EduBot Forest Studio"}</
616616

617617
const performResetPassword = async (isTeacher) => {
618618
if (!inputUser.trim() || !inputName.trim() || !inputPwd.trim()) { setError("Todos los campos son requeridos"); return; }
619-
if (!isValidPassword(inputPwd)) { setError("La nueva contraseña debe tener al menos 7 caracteres."); return; }
619+
if (!isValidPassword(inputPwd)) { setError("La nueva contraseña debe tener al menos 8 caracteres."); return; }
620620

621621
setLoading(true);
622622
try {
@@ -695,7 +695,7 @@ <h2 className="text-xl font-semibold text-white text-center">{isTeacher ? 'Nuevo
695695
<input type="text" className="w-full bg-gray-900 border border-gray-600 rounded-lg p-2 text-white outline-none focus:border-blue-500" placeholder={isTeacher ? "Ej: pedro.prof" : "Ej: juan123"} value={inputUser} onChange={(e) => setInputUser(e.target.value)} />
696696
</div>
697697
<div>
698-
<label className="block text-xs text-gray-400 mb-1">Contraseña (Mínimo 7 caracteres)</label>
698+
<label className="block text-xs text-gray-400 mb-1">Contraseña (Mínimo 8 caracteres)</label>
699699
<input type="password" className="w-full bg-gray-900 border border-gray-600 rounded-lg p-2 text-white outline-none focus:border-blue-500" placeholder="••••••" value={inputPwd} onChange={(e) => setInputPwd(e.target.value)} />
700700
</div>
701701
{error && <div className="text-red-400 text-xs bg-red-900/20 p-2 rounded border border-red-900/50">{error}</div>}
@@ -752,7 +752,7 @@ <h2 className="text-xl font-semibold text-white text-center">Recuperar Contrase
752752

753753
<input type="text" className="w-full bg-gray-900 border border-gray-600 rounded-lg p-2 text-white outline-none focus:border-blue-500 mb-2" placeholder="Usuario" value={inputUser} onChange={(e) => setInputUser(e.target.value)} />
754754
<input type="text" className="w-full bg-gray-900 border border-gray-600 rounded-lg p-2 text-white outline-none focus:border-blue-500 mb-2" placeholder="Nombre Completo Exacto" value={inputName} onChange={(e) => setInputName(e.target.value)} />
755-
<input type="password" className="w-full bg-gray-900 border border-gray-600 rounded-lg p-2 text-white outline-none focus:border-blue-500" placeholder="Nueva Contraseña (Mín 7)" value={inputPwd} onChange={(e) => setInputPwd(e.target.value)} />
755+
<input type="password" className="w-full bg-gray-900 border border-gray-600 rounded-lg p-2 text-white outline-none focus:border-blue-500" placeholder="Nueva Contraseña (Mín 8)" value={inputPwd} onChange={(e) => setInputPwd(e.target.value)} />
756756

757757
{error && <div className="text-red-400 text-xs bg-red-900/20 p-2 rounded border border-red-900/50">{error}</div>}
758758
<button onClick={() => performResetPassword(isTeacher)} disabled={loading} className={`w-full py-2 mt-2 rounded-lg font-bold shadow-lg bg-orange-600 hover:bg-orange-500 text-white shadow-orange-500/20 ${loading ? 'opacity-50' : ''}`}>{loading ? 'Procesando...' : 'Restaurar Contraseña'}</button>
@@ -892,8 +892,8 @@ <h2 className="text-2xl font-bold text-white mb-2">{steps[step].title}</h2>
892892

893893
// EXPRESIONES REGULARES DE SEGURIDAD
894894
const isValidName = (name) => /^[a-zA-ZáéíóúÁÉÍÓÚñÑ\s]+$/.test(name);
895-
const isValidTeacherUser = (user) => /^(?=.*[a-zA-Z])[a-zA-Z0-9._-]{2,15}$/.test(user);
896-
const isValidStudentUser = (user) => /^(?=.*[a-zA-Z])[a-zA-Z0-9]{2,8}$/.test(user);
895+
const isValidTeacherUser = (user) => /^(?=.*[a-zA-Z])[a-zA-Z0-9._-]{3,15}$/.test(user);
896+
const isValidStudentUser = (user) => /^(?=.*[a-zA-Z])[a-zA-Z0-9]{3,8}$/.test(user);
897897

898898
useEffect(() => {
899899
if (isOpen) {
@@ -946,7 +946,7 @@ <h2 className="text-2xl font-bold text-white mb-2">{steps[step].title}</h2>
946946
// LÓGICA DE SEGURIDAD Y ADMIN
947947
const handleChangePassword = async () => {
948948
if (!oldPwd || !newPwd) return;
949-
if (newPwd.length < 7) { showModal({ type: 'alert', title: 'Error', message: 'La nueva contraseña debe tener al menos 7 caracteres.', onConfirm: closeModal }); return; }
949+
if (newPwd.length < 8) { showModal({ type: 'alert', title: 'Error', message: 'La nueva contraseña debe tener al menos 8 caracteres.', onConfirm: closeModal }); return; }
950950
setLoadingPwd(true);
951951
try {
952952
const res = await window.eel.api_change_password(currentUsername, oldPwd, newPwd, userRole)();
@@ -997,7 +997,7 @@ <h2 className="text-2xl font-bold text-white mb-2">{steps[step].title}</h2>
997997
if (!isValidName(name)) { showModal({ type: 'alert', title: 'Error', message: 'Nombre inválido.', onConfirm: closeModal }); return; }
998998
if (editingAccount.role === 'teacher' && !isValidTeacherUser(username)) { showModal({ type: 'alert', title: 'Error', message: 'Usuario de profesor inválido.', onConfirm: closeModal }); return; }
999999
if (editingAccount.role === 'student' && !isValidStudentUser(username)) { showModal({ type: 'alert', title: 'Error', message: 'Usuario de estudiante inválido.', onConfirm: closeModal }); return; }
1000-
if (password && password.length < 7) { showModal({ type: 'alert', title: 'Error', message: 'La contraseña debe tener al menos 7 caracteres.', onConfirm: closeModal }); return; }
1000+
if (password && password.length < 8) { showModal({ type: 'alert', title: 'Error', message: 'La contraseña debe tener al menos 8 caracteres.', onConfirm: closeModal }); return; }
10011001

10021002
const res = await window.eel.api_edit_account(editingAccount.old_username, username, name, password, editingAccount.role)();
10031003
if (res.success) {
@@ -1012,7 +1012,7 @@ <h2 className="text-2xl font-bold text-white mb-2">{steps[step].title}</h2>
10121012
if (!name || !username || !password) { showModal({ type: 'alert', title: 'Error', message: 'Todos los campos son obligatorios.', onConfirm: closeModal }); return; }
10131013
if (!isValidName(name)) { showModal({ type: 'alert', title: 'Error', message: 'Nombre inválido.', onConfirm: closeModal }); return; }
10141014
if (!isValidStudentUser(username)) { showModal({ type: 'alert', title: 'Error', message: 'Usuario de estudiante inválido.', onConfirm: closeModal }); return; }
1015-
if (password.length < 7) { showModal({ type: 'alert', title: 'Error', message: 'La contraseña debe tener al menos 7 caracteres.', onConfirm: closeModal }); return; }
1015+
if (password.length < 8) { showModal({ type: 'alert', title: 'Error', message: 'La contraseña debe tener al menos 8 caracteres.', onConfirm: closeModal }); return; }
10161016

10171017
const res = await window.eel.api_create_student(username, password, name)();
10181018
if (res.success) {

0 commit comments

Comments
 (0)