Login Page

A complete authentication system with login and registration functionality built with React and Hono.

Features

  • šŸ” User authentication (login/logout)
  • šŸ“ User registration
  • šŸŖ Session management with cookies
  • šŸ’¾ SQLite database for user storage
  • šŸŽØ Beautiful UI with TailwindCSS
  • šŸ“± Responsive design
  • ⚔ Real-time form validation

Demo Credentials

  • Username: demo
  • Password: demo123

Project Structure

ā”œā”€ā”€ backend/
│   └── index.ts          # Hono API server with auth endpoints
ā”œā”€ā”€ frontend/
│   ā”œā”€ā”€ index.html        # Main HTML template
│   ā”œā”€ā”€ index.tsx         # React app entry point
│   └── components/
│       ā”œā”€ā”€ App.tsx       # Main app component
│       ā”œā”€ā”€ LoginForm.tsx # Login/registration form
│       └── Dashboard.tsx # Protected dashboard
ā”œā”€ā”€ main.tsx              # HTTP trigger entry point
└── README.md

API Endpoints

  • POST /api/login - Authenticate user
  • POST /api/register - Create new user account
  • POST /api/logout - End user session
  • GET /api/auth - Check authentication status

Database Schema

The app uses SQLite with a simple users table:

CREATE TABLE login_users_1 ( id INTEGER PRIMARY KEY AUTOINCREMENT, username TEXT UNIQUE NOT NULL, password TEXT NOT NULL, created_at DATETIME DEFAULT CURRENT_TIMESTAMP );

Security Features

  • HTTP-only cookies for session management
  • Secure cookie settings
  • Input validation
  • SQL injection protection with parameterized queries
  • Password length requirements

Usage

  1. Visit the login page
  2. Use demo credentials or create a new account
  3. Access the protected dashboard after authentication
  4. Sign out to return to the login page

Technology Stack

  • Frontend: React 18, TailwindCSS
  • Backend: Hono, SQLite
  • Platform: Val Town
  • Authentication: Cookie-based sessions