A secure and minimal JWT-based authentication system using React, Node.js, Express, MySQL2, and bcrypt. This project implements user registration, login, logout, token refresh, providing a robust foundation for secure web applications.
Register | Login |
---|---|
![]() |
![]() |
β
Register and Login with secure hashing
β
JWT Access + Refresh Token flow
β
MySQL2 for persistent user storage
β
Bcrypt for password encryption
β
Protected routes via middleware
β
Token storage and invalidation system
β
RESTful API with JSON responses
Layer | Technology |
---|---|
Frontend | React, Axios, React Router |
Backend | Node.js, Express |
Database | MySQL, MySQL2 (Driver) |
Security | bcrypt, JWT |
Config & Env | dotenv |
Dev Tools | Nodemon, Postman |
git clone https://github.com/amirmub/jwt-auth.git
cd jwt-auth/server
npm install
CREATE DATABASE jwt_auth;
CREATE TABLE users (
user_id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) NOT NULL,
firstname VARCHAR(255) NOT NULL,
lastname VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL
);
CREATE TABLE tokens (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
token TEXT NOT NULL,
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
);
npm start
cd ../client
npm install
npm run dev
git checkout -b feature-new-feature
git commit -m "Add new feature"
git push origin feature-new-feature
π§ Email: amirmubarek01@gmail.com
π» GitHub: @amirmub