JWT

1. Giới thiệu

2. Cài đặt app

2.1 Các công cụ sử dụng

  • Express

  • Dotenv

  • Mongoose

  • Bcrypt

  • JWT

2.1 Cài đặt API

  • Register : api/user/register

Register phải trải qua các bước sau: - Check Valid (Email, password, name, sdt) - Sử dụng @Happi/Joi - Check Exist Account - Mongoose DB - Hash password - Bcrypt - Create new Account - Mongoose DB

  • Login

Login cũng phải trải qua các bước sau: - Check Valid (Email, password) - Sử dụng @Happi/Joi - Check Exist Account - Mongoose DB (FindOne) - Check Hash password - Bcrypt - Save Information in header - JWT

  • Authentication (Xác thực)

Để xác thực một account cần: - Verify account - JWT - Take information from ID - Mongoose DB - Send back - Express

3. Code ví dụ

Cấu trúc thư mục

Last updated

Was this helpful?