Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/AndresLopezCorrales/La-casa-del-bordadito/llms.txt

Use this file to discover all available pages before exploring further.

La Casa del Bordadito uses Firebase Authentication to manage every user session. Two sign-in methods are available: email/password (with mandatory email verification) and Google Sign-In via Google Play Services. Both paths converge on the same Realtime Database user record and tie into OneSignal for targeted push notifications.
1

Register a new account

From the login options screen (OpcionesLogin), tap Ingresar con Email, then tap the Registrarme link to open Registro_email.Fill in three fields:
FieldValidation
EmailMust match Patterns.EMAIL_ADDRESS
PasswordMust not be empty
Repeat passwordMust match the first password field
On submit, firebaseAuth.createUserWithEmailAndPassword(email, password) is called. On success the app immediately fires sendEmailVerification() and navigates to VerificarEmailActivity.
2

Verify your email address

VerificarEmailActivity polls Firebase every 3 seconds by calling firebaseAuth.currentUser?.reload() and checking user.isEmailVerified. The screen shows a Reenviar button if the email never arrived.Once the flag flips to true:
  1. The user record is written to Realtime DB → Usuarios/{uid} with proveedor = "Email".
  2. OneSignal.login(uid) links the device for push notifications.
  3. A welcome email is sent via EmailJS.
  4. The app navigates to MainActivity and finishes the back-stack.
3

Sign in to an existing account

Enter email and password on Login_email and tap Ingresar. The app calls firebaseAuth.signInWithEmailAndPassword(email, password).On success, user.isEmailVerified is checked:
  • VerifiedcomprobarDatosUsuario(uid) confirms the Realtime DB record exists, calls OneSignal.login(uid), and opens MainActivity.
  • Not verified → a toast is shown, the session is signed out, and the user is redirected to VerificarEmailActivity.

User record in Realtime Database

Every authenticated user has a document at Usuarios/{uid} in the Firebase Realtime Database. The fields written at registration time are:
{
  "uid": "abc123xyz",
  "email": "usuario@example.com",
  "nombres": "Ana García",
  "urlImagenPerfil": "",
  "proveedor": "Email",
  "fecha_nac": "",
  "codigoTelefono": "",
  "telefono": "",
  "online": true,
  "escribiendo": "",
  "tiempo": 1718300000000,
  "esAdmin": false,
  "esSoporte": false
}
FieldTypeDescription
uidStringFirebase Auth UID
emailStringAccount email address
nombresStringDisplay name (defaults to the part of the email before @ on first login)
urlImagenPerfilStringFirebase Storage download URL, empty until set
proveedorString"Email" or "Google"
fecha_nacStringDate of birth (set in profile, empty at registration)
codigoTelefonoStringInternational dial code, e.g. "+52"
telefonoStringPhone number without the dial code
onlineBooleanReal-time presence flag
escribiendoStringTyping-indicator flag used in the support chat; empty when not typing
tiempoLongSystem.currentTimeMillis() at registration
esAdminBooleanGrants admin panel access
esSoporteBooleanGrants support-chat access

Online presence tracking

ApplicationClass registers an ActivityLifecycleCallbacks listener at the application level. Whenever the activity count crosses the foreground/background boundary, actualizarEstadoOnline() is called:
companion object {
    fun actualizarEstadoOnline(online: Boolean) {
        val uid = FirebaseAuth.getInstance().uid ?: return
        val ref = FirebaseDatabase.getInstance().getReference("Usuarios").child(uid)

        if (online) {
            ref.child("online").setValue(true)
            ref.child("online").onDisconnect().setValue(false)
        } else {
            ref.child("online").setValue(false)
        }
    }
}
The .onDisconnect().setValue(false) hook ensures the online flag is cleared by Firebase servers even if the device loses connectivity unexpectedly.

Session check on launch

OpcionesLogin.comprobarSesion() runs every time the login screen is created. It guards against three states:
private fun comprobarSesion() {
    val user = firebaseAuth.currentUser
    if (user != null) {
        if (user.providerData.any { it.providerId == "password" } && !user.isEmailVerified) {
            firebaseAuth.signOut()
        } else {
            startActivity(Intent(this, MainActivity::class.java))
            finishAffinity()
        }
    }
}
  • No current user → stay on OpcionesLogin.
  • Email/password user whose email is unverified → sign out and stay on OpcionesLogin.
  • Any verified user → go straight to MainActivity.

OneSignal device linking

After every successful authentication, com.onesignal.OneSignal.login(user.uid) is called. This associates the device’s push token with the Firebase UID so that targeted notifications (e.g., order updates, workshop announcements) are delivered to the correct person.
If you registered with an email address and password, you must click the verification link sent to your inbox before the app will let you sign in. The session is signed out automatically if the email remains unverified. Check your spam folder if the email does not arrive within a few minutes, or tap Reenviar on the verification screen.

Build docs developers (and LLMs) love