Skip to content

Repository files navigation

Next.js Authentication Course Application

This is a Next.js application with basic authentication functionality using React and TypeScript.

Features

  • User Registration: Form to create new accounts
  • Login: Authentication for existing users
  • Protected Home Page: Only accessible to authenticated users
  • Responsive Design: Modern interface with Tailwind CSS
  • Course Navigation: Sidebar with chapter organization
  • Interactive Content: Videos, text content, and quizzes

Available Routes

  1. / - Automatically redirects to /login
  2. /signup - Registration page
  3. /login - Login page
  4. /home - Main page (requires authentication)
  5. /home/introduccion - Course introduction
  6. /home/capitulo1/video - Chapter 1 video
  7. /home/capitulo1/texto - Chapter 1 text content
  8. /home/capitulo1/preguntas - Chapter 1 quiz
  9. /home/capitulo2/video - Chapter 2 video
  10. /home/capitulo2/texto - Chapter 2 text content
  11. /home/capitulo2/preguntas - Chapter 2 quiz

Functionality

Registration (/signup)

  • Form with fields: Name, Phone, Email
  • Registration button (placeholder - does nothing for now)
  • Link to go to login

Login (/login)

  • Form with fields: Email, Password
  • On successful login, sets a global user variable
  • Automatically redirects to /home

Course Home (/home)

  • Verifies if user is authenticated
  • If no user, redirects to /login
  • Shows course navigation with sidebar
  • Includes logout button

Course Content

  • Introduction: Welcome content with course overview
  • Videos: Embedded YouTube videos for each chapter
  • Text Content: Detailed theoretical content with Lorem Ipsum placeholders
  • Quizzes: Interactive questionnaires with multiple choice questions

Technologies Used

  • Next.js 15 - React framework
  • React 19 - UI library
  • TypeScript - Static typing
  • Tailwind CSS - CSS framework

Installation and Setup

  1. Install dependencies:
npm install
  1. Run in development mode:
npm run dev
  1. Open http://localhost:3000 in your browser

Course Structure

The application includes a course with the following structure:

  • Introduction: Course overview and objectives
  • Chapter 1:
    • Video: Fundamentals with embedded YouTube content
    • Text: Detailed theoretical content
    • Quiz: Interactive assessment
  • Chapter 2:
    • Video: Advanced concepts
    • Text: In-depth theoretical material
    • Quiz: Advanced assessment

Pagos con Stripe

La aplicación incluye integración con Stripe para procesar pagos del curso.

Configuración

  1. Copia .env.example a .env.local
  2. Añade tus claves de Stripe (Dashboard → Developers → API keys)
  3. Configura Firebase Admin:
    • Opción A: Descarga la cuenta de servicio desde Firebase Console (Project Settings → Service accounts) y guarda como serviceAccountKey.json en la raíz del proyecto
    • Opción B: Define FIREBASE_SERVICE_ACCOUNT_JSON con el contenido del JSON como string (útil para Vercel)
  4. Añade FIREBASE_WEB_API_KEY (la misma apiKey de firebase.ts, en Firebase Console > Project Settings > General). Para que los emails funcionen:
    • Authentication > Sign-in method: habilitar "Email/Password"
    • Project Settings > Authorized domains: incluir localhost (dev) y tu dominio (producción)

Probar el webhook localmente

Stripe necesita un endpoint público para enviar eventos. En local, usa Stripe CLI para reenviar eventos a tu servidor:

# Instala Stripe CLI: https://stripe.com/docs/stripe-cli
stripe listen --forward-to localhost:3000/api/stripe/webhook

El comando mostrará un webhook signing secret (empieza con whsec_). Añádelo a .env.local como STRIPE_WEBHOOK_SECRET.

En otro terminal, ejecuta la app y procesa un pago de prueba. Stripe CLI enviará el evento checkout.session.completed a tu webhook local.

Flujo de pago

  1. Usuario se registra como lead en /signup (sin límite)
  2. Usuario va a /purchase, ingresa email y es redirigido a Stripe Checkout
  3. Tras el pago, Stripe redirige a /purchase/success
  4. En la página de éxito, el usuario configura su contraseña (o recibe un email)
  5. Con la contraseña configurada, puede iniciar sesión en /login y acceder a /course

Important Notes

  • El dashboard muestra leads y usuarios activos desde Firestore
  • La autenticación usa Firebase Auth
  • El contenido del curso usa placeholders (Lorem Ipsum, videos de ejemplo)

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages