Create User Management (Role Based) API With Dynamic Policies In Asp.Net Core Web API

Опубликовано: 10 Март 2025
на канале: Code Hub
1,575
45

In this video, we'll create user management API to use in our flutter (or any other app we want).

For this purpose, we'll make necessary changes in one of our previously created API (which is available on GitHub). If you want to watch the tutorial of that API then watch this video:    • Create Asp.Net Core Web API With JWT ...  

In this API, we'll create Account Controller which handles the registration and login requests. We created both custom registration and login method from scratch for this purpose.

Then, we'll create Admin and User Controllers and create necessary and relevant actions for them.

And Finally, we'll create custom authorization classes to generate dynamic policies to handles all the roles. We need these classes because admin can create new roles and we generate new policies for the new role. We can't use hard-coded policies for this purpose because we don't know how many roles would be there. To solve this, we need dynamic policies which can handle all roles.

-------------------------------------------------------------------------------------
What will you learn:
1. Create Authentication and Authorization in API
2. Create Role Based Authorization
3. Create new Roles on runtime
4. Create Dynamic Policies to handle roles
5. Admin Controller to control all the actions on API / Database
6. Users controller with the ability to handle their profile
7. Custom Registration and Login methods in Asp.net Core Web API
8. Assign roles to users on time of registration
9. Seed / add Admin (user), roles to database on database Creation time
10. Assign Admin Role to Admin while seeding data to admin
11. Custom verification on login and registration time
12. Generate custom error and success message / responses
13. Login using email instead of username in Asp.net core web API
14. Prevent duplicate emails in Asp.net core web API
15. Verify email address while registration
16. Generate Dynamic Role Handling classes
17. Generate Dynamic Policy Handler classes
18. Test API with Postman

-------------------------------------------------------------------------------------
Time Stamps:
00:00 Intro and API setup
00:32 Edit Program.cs File
01:15 Create Models
02:25 Seed Admin Data & Roles To Database
05:23 Create Custom Register Method
08:20 Create Custom Login Method
08: 46 Create Admin Controller
20:55 Create User Controller
25:09 Create Migrations & Database
26:04 Create Dynamic Policies
30:57 API Testing With Postman

-------------------------------------------------------------------------------------
Related Video Links:
Create Asp.Net Core Web API With JWT Role Based Authorization Using Identity Framework From Scratch:    • Create Asp.Net Core Web API With JWT ...  

Create Asp.Net Core Web API with JWT Authentication And Authorization [Complete Tutorial]:    • Create Asp.Net Core Web API with JWT ...  

Asp.Net Core Razor Pages CRUD Operation In .Net 8 [Complete Tutorial]:    • Asp.Net Core Razor Pages CRUD Operati...  

Create Flutter App With Asp.Net Core Web API As Backend [Full Tutorial]:    • Create Flutter App With Asp.Net Core ...  

-------------------------------------------------------------------------------------
Source Codes:
Source code of this api: https://github.com/FLDevelopers/Role-...

Source code of old api (which we edited): https://github.com/FLDevelopers/AspNe...

-------------------------------------------------------------------------------------
I hope, you'll like this video. If you have any question related to this video then ask in comments section without any hesitation.

Also Don't forget to like this video and also share it with your friends. Also don’t forget to subscribe our channel and also hit that notification bell to get the notification of our latest video.

-------------------------------------------------------------------------------------
Join WhatsApp Channel: https://whatsapp.com/channel/0029VaE0...
Check out our website: https://www.freetrained.com/
Facebook Page Link:   / free_trained  
Facebook Group Link:   / 1746009532359857  

Please Subscribe Our YouTube Channel For More interesting Videos And Don't Forget To Share Our Channel With Your Friends.

Note: *Please Turn Off Any Ad Blocker Software or add-on to support us.
-------------------------------------------------------------------------------------
Additional Tags:
#aspnet #role #authorization #authentication #coding #programming #tutorial #course #flutter #aspdotnetcore #webapi #api

-------------------------------------------------------------------------------------
Music Attribution:
Almost in F - Tranquillity by Kevin MacLeod is licensed under a Creative Commons Attribution 4.0 license. https://creativecommons.org/licenses/...
Source: http://incompetech.com/music/royalty-...
Artist: http://incompetech.com/