Backend car rental service application created for university project.
Project is a web api that has two type of users. Admin and basic User
Admin can add new cars and user can rent available cars.
- C#
- Sqlite database
- ASP.NET 5.0
- Register new user
- Login user (JWT access token contains claims such as role, user id and email)
- Obtain user information by token
- Refresh user access token with rotating refresh token and invalidate the old one
- Add new car (Only for Admin)
- Delete car (Only for Admin)
- Update car (Only for Admin)
- Get car by id
- Get all cars
- Clone repo to your chosen destination.
- Open project in IDE
- Install all NuGet packages
- First apply all migrations to database
dotnet ef database update
- If there wasn't any error you can simply type
dotnet watch run
to run the application
You can reach api interactive documentation at: https://localhost:5001/swagger/index.html
- To get access to request that need authentication first you have to sign in (manually e.g. via postman or using login section in current page)
- After successful login, copy
access
token - Find and click
Authorize
button at the top of page - Select input and type
Bearer <YOUR_JWT_TOKEN>
- Now you can reach endpoints that require users to be authenticated
User registration is available at endpoint: https://localhost:5001/api/auth/register
Body of request should be formatted in JSON.
Example body:
{
"email": "user@example.com",
"password": "string",
"firstName": "string",
"lastName": "string"
}
User login is available at endpoint: https://localhost:5001/api/auth/login
Body of request should be formatted in JSON.
Example body:
{
"email": "user@example.com",
"password": "string"
}
User details is available at endpoint: https://localhost:5001/api/auth/getMe
Body of request should be formatted in JSON.
To get user details you should provide header with "Authorization"
key and "Bearer <user_access_token>"
value
To refresh access
token go at endpoint: https://localhost:5001/api/auth/refreshToken
Body of request should be formatted in JSON.
You will get new access
and refresh
token. From now old refresh
token is invalid
{
"token": "YOUR_REFRESH_TOKEN_STRING"
}
Project is in progress.
Project created by: Jan Piaskowy