A professional, accessible web application for user authentication using JWT tokens, built with pure HTML5, CSS3, and JavaScript.
- User registration and login
- JWT-based authentication
- Protected routes
- Responsive design following modern UI/UX trends
- Accessibility compliance (WCAG guidelines)
- Client-side form validation
- Secure token storage in localStorage
- Ensure Node.js and npm are installed.
- Install dependencies:
npm install - Set up environment variables:
- Create a
.envfile in the root directory - Add
JWT_SECRET=your_secret_key_here
- Create a
- Start the server:
npm startornode index.js - Open
index.htmlin your browser to access the login page.
- Login: Navigate to
index.html, enter credentials, and submit. - Register: Go to
register.htmlto create a new account. - Protected Content: After login, access
protected.htmlto view secured content. - Logout: Click the logout button on the protected page.
index.html: Login pageregister.html: Registration pageprotected.html: Protected content pagestyle.css: Modern, responsive stylesscript.js: Client-side JavaScript for forms and API callsindex.js: Express server (backend)middleware/authenticateToken.js: JWT middlewareroutes/: API route handlers
This app follows accessibility best practices:
- Semantic HTML structure
- ARIA labels and roles
- Keyboard navigation support
- High contrast support
- Screen reader friendly
- Login/Register fails: Check server is running on port 8000/hosted URL and
.envis configured. - Token errors: Ensure JWT_SECRET is set and tokens aren't expired.
- Styling issues: Clear browser cache or check CSS file paths.
- Network errors: Verify backend endpoints match client requests.
- Tokens are stored in localStorage (not secure for production).
- Use HTTPS in production.
- Implement proper password hashing on the server side.
