Express jwt authorization app created in educational purposes. Only API.
App that implements authorization with JWT token.
The front created on the base of API.
It uses bcryptjs to hash and verify passwords, eta to render pages, joi to validate data, jwt as an authorization token and mongoDB (mongoose) as a database.
# Clone repo
git clone https://github.com/1mpossible-code/jwt-authorization
# Cd in it
cd jwt-authorization
# Install packages
npm install
# Copy .env.example and edit it optionally
cp .env.example .env
# Compose up
docker-compose up
You will have server on http://localhost:3000/
All routes described here:
Method | Route | Params | Description |
---|---|---|---|
GET | /register | Render register page | |
POST | /register | {name: String, email: String, password: String} | Register new user. Then show new created user's id |
GET | /login | Render login page | |
POST | /login | {email: String, password: String} | Login user. It will create cookie JWT token. Then redirect to test page |
GET | /logout | Logout user. Delete token from cookie | |
GET | /auth/me | Get user's data in JSON format: {_id: String, name: String, email: String} | |
GET | /test | Test token if token is invalid or no token at all, else you will see the information of current user | |
GET | /test/routes | Render all routes page | |
GET | / | Redirect to '/test/routes' |
Feel freely to contribute this project. Issues and PRs are welcome!
You can mail to [email protected]
to contact the author
Copyright © 2021 1mpossible-code. This project is GPLv3 licensed.