To run this project, you need to:
- Install project on your machine
- Change server name in application.json to that one your machine has
- Run the app, all migrations will be applied automatically :)
API runs on https://localhost:7145 (changable) and has 2 controllers: UserController and TaskController. Lets walk over their endpoints:
- /users/login - POST, allows users to log in using LoginRequestDto, which consists of Username and Password fields. If login was successful, user gets back responce with token inside, which they can use to authorize and access TaskController endpoints.
- /users/register - POST, allows user to register using RegistrationRequestDto, which consists of Email, Password and Username fields. If success, user is created and saved in db, with hashed password.
- /tasks - GET, returns authorized user list of their tasks. Can be sorted by Priority, DueDate, Status, and ordered by Priority and/or DueDate.
- /tasks/{id} - GET, returns user task based on id of that task if this task is assigned to that user. Else, returns exception.
- /task - POST, creates task based on TaskOfUserDto, which contains Id, Name, Description, Status, Priority, DueDate and UserId as fields. Id and UserId are not requiered inputs, as they are changed authomatically, in case of UserId based on user that sends data.
- /task - PUT, updates task based on same TaskOfUserDto. Does NOT update such fields as Id, UserId and CreatedTime.
- /task/{id} - DELETE, removes task with specified id from db, if it is assign to the user making request.
For authentication I made simple JwtTokenGenerator, that has claims for user Id, email, username. I also created PasswordHasher, that uses Pbkdf2 and HMACSHA256 algorithms. Finally, I created AuthService, that allows user to login and register, using PasswordHasher and JwtTokenGenerator to do it. It also tells user if their password is too easy (like special characters, number, upper/lowercase letters, etc.)