Create User Management (Role Based) API With Dynamic Policies In Asp.Net Core Web API
Code Hub
View ChannelAbout
Welcome to Code Hub! 🚀 At Code Hub, we turn complex programming into simple, easy-to-follow lessons. Whether you’re learning Flutter, .NET, Svelte, or exploring real-world projects, our tutorials help you build apps, solve problems, and level up your coding skills. Join other passionate learners who are already building amazing projects with us. Subscribe now and start your journey from ideas to execution – one line of code at a time. Topics We Cover: Mobile App Development Web Development API Development & Integrations Real-World Projects & Tips Tech Updates Code smarter. Build faster. Learn forever. 💻
Latest Posts
Video Description
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: https://youtu.be/brxStRVyJiM 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: https://youtu.be/brxStRVyJiM Create Asp.Net Core Web API with JWT Authentication And Authorization [Complete Tutorial]: https://youtu.be/7B0oyWtLONk Asp.Net Core Razor Pages CRUD Operation In .Net 8 [Complete Tutorial]: https://youtu.be/RrEWce0pUJ0 Create Flutter App With Asp.Net Core Web API As Backend [Full Tutorial]: https://youtu.be/JK-7-cVgHxA ------------------------------------------------------------------------------------- Source Codes: Source code of this api: https://github.com/FLDevelopers/Role-Based-User-Management-API-Using-Dynamic-Policies-In-Asp.Net-Core-Web-API Source code of old api (which we edited): https://github.com/FLDevelopers/AspNetCoreWebApiWithRolesBasedAuthorization ------------------------------------------------------------------------------------- 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/0029VaE0W6HA2pLH5dN39n36 Check out our website: https://www.freetrained.com/ Facebook Page Link: https://www.facebook.com/Free_Trained Facebook Group Link: https://www.facebook.com/groups/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/by/4.0/ Source: http://incompetech.com/music/royalty-free/index.html?isrc=USUAN1100394 Artist: http://incompetech.com/
Boost Your API Development
AI-recommended products based on this video

Reatan S8 Mini PC Gaming with Intel Core i9 12900H(14C/20T 5.0 GHz), 32GB DDR5 Dual Channel 1TB NVMe SSD, Mini Desktop Computer Triple Display Support 8K WiFi6 BT5.2 USB-C

GMKtec Mini PC Intel Core i7-1195G7 (Turbo 5.0 GHz) 32GB DDR4 1TB SSD Desktop Mini Computers W11 Pro, WiFi 6, BT 5.2/DP, HDMI/RJ45 2.5G/USB4.0

Thdeukoty Mini PC i9-12900H 14 Core Up to 5.0GHz, Mini Desktop Computer Windows 11 Pro (TPM2.0), 64G RAM 1T Pcie 4.0 SSD, DP/HDMI/Type-C Triple Display, WiFi 6E Bluetooth5.3 for Home/Business

Car Window Shades,Highly Elastic Universal Car Rear Side Window Screen Mosquito Net Covers for 96% of Cars SUVs,Anti-Sun Glare, Reduce UV Rays, Privacy Protection(2 Pack)

MT7601 USB Adapter USB Antenna, Computer Adapter USB Adapter with Integrated Antenna for Windows Desktop Laptop

TP-Link USB Bluetooth Adapter for PC, 4.0 Bluetooth Dongle Receiver (UB400) - Support Windows 11/10/8.1/8/7/XP for Desktop, Laptop, Mouse, Keyboard, Printers, Headsets, Speakers, PS4/ Xbox Controllers

10Gtek USB WiFi Adapter, for PC, AC600M USB WiFi Dongle 802.11ac Wireless Network Adapter with Dual Band 2.4GHz/5Ghz for Desktop Laptop Support Windows 10/8/7/XP, MAC OS, Linux etc

BrosTrend 1200Mbps USB WiFi Adapter for Windows 11/10/8/7/XP of PC Desktop Laptop, Dual Band 5GHz 867Mbps, 2.4GHz 300Mbps, USB 3.0, Network Card WLAN

TP-Link USB WiFi Adapter for PC(TL-WN725N), N150 Wireless Network Adapter for Desktop - Nano Size WiFi Dongle for Windows 11/10/7/8/8.1/XP/ Mac OS 10.9-10.15 Linux Kernel 2.6.18-4.4.3, 2.4GHz Only

BrosTrend 1800Mbps WiFi 6 Linux WiFi Adapter for PC and Raspberry Pi 2+, Long Range USB WiFi Dongle Linux for Ubuntu, Mint, Debian, Kubuntu, Lubuntu, Zorin, Windows 11/10, Dual Band Wireless Antenna

10Gtek USB WiFi Adapter, for PC, AC600M USB WiFi Dongle 802.11ac Wireless Network Adapter with Dual Band 2.4GHz/5Ghz for Desktop Laptop Support Windows 10/8/7/XP, MAC OS, Linux etc

