Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Hi,
I have completed the task, please see the attachment.
I created a new project "UserAuthApp" and implemented authentication and authorization.
I also combined/integrated this code in the project
Please follow below steps to test the project.
Note: In the database User table Samehra has Admin role while Smith has User role.
Logging In:
Send a post request to the following endpoint with below data using PostMan.
Endpoint: http://localhost:7429/api/users/authenticate
Data: {"Username":"Samehra", "Password":"pass111"}
In response you will get user info with a token.
Below endpoint can be accessed by admin role only.
http://localhost:7429/api/users/adminendpoint
Below endpoint can be accessed by user role only.
http://localhost:7429/api/users/userendpoint
To call the above endpoints, you will need to send the token (that you got using the authenticate endpoint) in the header.
The key should be "Authorization" while its value should be "Bearer [token]". Replace "[token]" with the actual token.
If you call these endpoints without any token, it will return 401 - Unauthorized.
If you call an endpoint that's not accessible by that person/role, it will return 403 - Forbidden.
Please let me know if you have questions.