Skip to content

Simple Todo app where user can login his account and get access only his todo and their also an admin who have all access to edit, delete, get user's data.

Notifications You must be signed in to change notification settings

saminyasar004/todo-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Todo App

Simple Todo app where user can login his account and get access only his todo and their also an admin who have all access to edit, delete, get user's data.

Website Facebook Follow Facebook Page Instagram Follow Twitter Follow Stack Overflow Github Follow

Schema

  • User

    • _id
    • name
    • email unique
    • password
    • role - [admin, user]
    • accountStatus - [pending, active, rejected]
  • Todo

    • _id
    • title unique
    • description
    • todoStatus - [incomplete, inProgress, completed]
    • authorId
  • Token

    • _id
    • token
    • authorId

API Router Endpoints

  • Admin

    • Authorization and JWT Token require

    • /api/v1/admin/u/all - GET - Return all users

    • /api/v1/admin/u/:userId - PATCH - Only edit accountStatus and role

  • User

    • /api/v1/u/register - POST - Register a new user
    • /api/v1/u/login - GET - Login a user and return a JWT token
    • /api/v1/u/logout - GET - Expire the JWT for a logged in user
    • /api/v1/u/update - PATCH - Update only user's name JWT require
    • /api/v1/u/forgetPassword - POST - Get a pincode in user's mail to change password
    • /api/v1/u/changePassword - PATCH - [pinCode, oldPassword, newPassword] - update the user's password
  • Todo

    • All routes below only works for the logged in user && Authentication require

    • /api/v1/t/new - POST - Creates a new Todo and authenticate user by JWT token

    • /api/v1/t/:todoId - GET - Get a single Todo and authenticate user by JWT token

    • /api/v1/t/all - GET - Get all Todos and authenticate user by JWT token

    • /api/v1/t/:todoId - PATCH - Update acceptable information of the requested Todo and authenticate user by JWT token

    • /api/v1/t/:todoId - DELETE - Delete the requested Todo and authenticate user by JWT token

Features

  • Admin

    1. The first user of this system will be an admin
    2. Admin can get all user's data (except password)
    3. Admin can edit an user's accountStatus and role
  • User

    1. If the user's accountStatus is pending then user couldn't create any todo untill the admin active this account. only can login.
    2. If the user's accountStatus is rejected then user couldn't login. He must have to contact with the admin through email to activate his account.
  • Token

    1. Whenever a user/admin login he gets a JWT token and then the token will be saved in the token database. An user/admin can have only one valid token at a time.

Happy Coding. 🚀

About

Simple Todo app where user can login his account and get access only his todo and their also an admin who have all access to edit, delete, get user's data.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published