Este usuario ya existe o es inválido
Mínimo 8 caracteres
Mayúscula y Minúscula
Un número
Un símbolo (.@$!%*#?&)
Correo inválido o ya en uso
Número incompleto o ya registrado
¿Ya tienes cuenta? Inicia sesión

¡Revisa tu correo!

Hemos enviado un enlace de confirmación. Debes activar tu cuenta para poder ingresar.

Volviendo al login en:

8
const firebaseConfig = { apiKey: "AIzaSyBJnRxHm3FKewC6DG_HZkxj5MDA5QCRQm8", authDomain: "investepapp.com", // <--- IMPORTANTE: Ya no es firebaseapp.com databaseURL: "https://investepapps-default-rtdb.firebaseio.com", projectId: "investepapps", storageBucket: "investepapps.firebasestorage.app", messagingSenderId: "656137226685", appId: "1:656137226685:web:8365880421844a5b392ad4" }; if (!firebase.apps.length) firebase.initializeApp(firebaseConfig); const db = firebase.database(); const auth = firebase.auth(); db.ref('lists/countries').once('value', (snap) => { const list = document.getElementById('countries-list'); snap.forEach((child) => { let opt = document.createElement('option'); opt.value = child.val(); list.appendChild(opt); }); }); const phoneInput = document.querySelector("#regPhone"); const iti = window.intlTelInput(phoneInput, { initialCountry: "us", separateDialCode: true, utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js" }); const setUI = (el, cond, errId) => { el.classList.toggle('valid', cond); el.classList.toggle('invalid', !cond); if (errId) document.getElementById(errId).style.display = !cond ? 'block' : 'none'; checkAll(); }; const formatProperCase = (str) => str.toLowerCase().replace(/\b\w/g, s => s.toUpperCase()); const email = document.getElementById('regEmail'), cEmail = document.getElementById('confirmEmail'); const pass = document.getElementById('regPass'), cPass = document.getElementById('confirmPass'); const userInput = document.getElementById('regUser'), nameInput = document.getElementById('regName'); let userTimeout; userInput.oninput = () => { userInput.value = userInput.value.toLowerCase().replace(/[^a-z0-9]/g, ''); clearTimeout(userTimeout); userTimeout = setTimeout(async () => { const val = userInput.value.trim(); if (val.length >= 4) { const snap = await db.ref('users').orderByChild('user').equalTo(val).once('value'); setUI(userInput, !snap.exists(), 'errUser'); } else { userInput.classList.remove('valid', 'invalid'); document.getElementById('errUser').style.display = 'none'; } }, 500); }; nameInput.oninput = () => setUI(nameInput, nameInput.value.trim().length >= 5, null); let emailTimeout; email.oninput = () => { email.value = email.value.toLowerCase(); const isValidFormat = /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email.value); clearTimeout(emailTimeout); emailTimeout = setTimeout(async () => { if (isValidFormat) { const snap = await db.ref('users').orderByChild('email').equalTo(email.value).once('value'); setUI(email, !snap.exists(), 'errEmail'); } else { setUI(email, false, 'errEmail'); } }, 500); }; cEmail.oninput = () => { cEmail.value = cEmail.value.toLowerCase(); setUI(cEmail, cEmail.value === email.value && cEmail.value !== "", null); }; let phoneTimeout; phoneInput.oninput = () => { clearTimeout(phoneTimeout); phoneTimeout = setTimeout(async () => { const isValid = iti.isValidNumber(); if (isValid) { const snap = await db.ref('users').orderByChild('phone').equalTo(iti.getNumber()).once('value'); setUI(phoneInput, !snap.exists(), 'errPhone'); } else { setUI(phoneInput, false, 'errPhone'); } }, 500); }; pass.oninput = () => { const v = pass.value; const checks = { len: v.length >= 8, case: /[a-z]/.test(v) && /[A-Z]/.test(v), num: /\d/.test(v), sym: /[^a-zA-Z0-9\s]/.test(v) }; document.getElementById('c-len').className = 'check-item ' + (checks.len ? 'met' : ''); document.getElementById('c-case').className = 'check-item ' + (checks.case ? 'met' : ''); document.getElementById('c-num').className = 'check-item ' + (checks.num ? 'met' : ''); document.getElementById('c-sym').className = 'check-item ' + (checks.sym ? 'met' : ''); setUI(pass, Object.values(checks).every(Boolean), null); }; cPass.oninput = () => setUI(cPass, cPass.value === pass.value && cPass.value !== "", null); function checkAll() { const validos = document.querySelectorAll('.valid').length; const invalidos = document.querySelectorAll('.invalid').length; document.getElementById('btnSubmit').disabled = !(invalidos === 0 && validos >= 7); } function showSuccess() { document.getElementById('register-state').style.display = 'none'; document.getElementById('success-state').style.display = 'block'; document.getElementById('main-card').style.maxWidth = '450px'; let count = 8; const timerEl = document.getElementById('timer'); const interval = setInterval(() => { count--; timerEl.innerText = count; if (count <= 0) { clearInterval(interval); window.location.href = "index.html"; } }, 1000); } document.getElementById('registerForm').addEventListener('submit', async (e) => { e.preventDefault(); const btn = document.getElementById('btnSubmit'); btn.disabled = true; btn.innerText = "PROCESANDO..."; const cleanName = formatProperCase(nameInput.value.trim()); const dataUser = userInput.value.trim(); const dataEmail = email.value.trim(); const dataPhone = iti.getNumber(); try { // 1. Crear usuario const cred = await auth.createUserWithEmailAndPassword(dataEmail, pass.value); // 2. Enviar verificación de email await cred.user.sendEmailVerification(); // 3. Guardar datos en DB await db.ref('users/' + cred.user.uid).set({ user: dataUser, email: dataEmail, phone: dataPhone, name: cleanName, country: document.getElementById('regCountry').value, rol: 'viewer', status: 'activo', fecha_registro: new Date().toISOString() }); showSuccess(); } catch (err) { alert("Error: " + err.message); btn.disabled = false; btn.innerText = "CREAR CUENTA"; } }); const setupT = (id, inp) => document.getElementById(id).onclick = () => { const i = document.getElementById(inp); i.type = i.type === 'password' ? 'text' : 'password'; document.getElementById(id).classList.toggle('fa-eye-slash'); }; setupT('t1', 'regPass'); setupT('t2', 'confirmPass');