Thank you @kudvenkat, any way to store the claims in a table in DataBase? the idea is implement a UI to add,edit, remove the claims like what you did with the roles.
Venkat I have question please .. is there any other ways to store claims other than using Static Class "in this demo ClaimsStore" ? and what is the real world projects's way to store claims ? I don't know I feel I understand it but there's something missing
The static class creates these claims that are accessible from anywhere in the namespace. If you wanted to store this on the database you could use the same method done for your employees in AppDbContext.
This piece of code appears in so many actions methods: var user = await _userManager.FindByIdAsync(userId); if (user == null) { ViewBag.ErrorMessage = $"Specified user Id {userId} does not exist"; return View("NotFound"); } I really wish I can put it into its own function. But then the funtion will need to return either a user or a View, which doesn't seem possible?
if you change your ClaimStore object (add/remove i.e. rename collection items), those changes will be in UI, and when you save it, all existing claims for current user are deleted and new ones added into DB. So effectively it is renaming.
Hi Kudvenkat, Im here regarding this issue i have just encountered regarding this very tutorial video I am commenting under. I followed your code word by word and yet when i click on update for updating user claims, the http post request does not retrieve the userId value from Url and hence because its null so it redirects me to notfound page. i have dictated my code with yours word to word and there is no difference but somehow the problem is still there. what would you suggest in order to resolve this issue. Anxiously waiting for your response.....
The value of the userId property in the POST action is actually set in GET action. First, check that you have: "UserClaimsViewModel model = new UserClaimsViewModel(){UserId = userId};". If so, the userId parameter in the GET action is probably null. Check that the name of the "userId" paramether in GET action is the same as in EditUser view where you click Manage Claims button. asp-route-userId="@Model.Id".
I dont think you still have this problem, actually I had a doubt regarding this, I asked in the comments section If you know the answer please reply. How I overcome this problem is I set hidden field for UserId inside the from tag and when I click Update, user id is binding to ViewModel UserId prop, so I am able to acces in post action method
I am getting so confusing here. First, Claims are identify the who user is, that dont show what user can do? But bases on your example. user Claims' show what user can do. That are very similar role/permission, a role contains some permissions. Is it right? Claims using by Microsoft is same concept of permission?
Hi - is the misspelling of "Claims" as "Cliams" in the UserClaimsViewModel purposely done? using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace EmployeeManagement.ViewModels { public class UserClaimsViewModel { public UserClaimsViewModel() { Cliams = new List(); } public string UserId { get; set; } public List Cliams { get; set; } } }
What I don't understand, that he is removing the Claims "var result = await userManager.RemoveClaimsAsync(user, userClaims)", than adds the claim ? Why would remove it like this ? Can someone explain ? It's a little bit confusing Thank you. In the past Post operations, he would check if the value is selected.
its like adding a fresh copy to your database of your claims. by removing the claims your database adds a new copy of your claims and replace it with the old one.
Hello Pavan - We do not have a Git hub link, but you can download the source code from the following page.I have also included all the .NET Core tutorial videos, slides and text articles in sequence on this page. Hope you will find it handy. www.pragimtech.com/courses/asp-net-core-mvc-tutorial-for-beginners/ When you have some time, can you please leave your rating and valuable feedback on the reviews tab. It really helps us. Thank you. Good luck and all the very best with everything you are doing.
@@Csharp-video-tutorialsBlogspot Hi can you please explain me this. Isn't this similar to adding roles to the user(video 91)? There we did not add any new model class for stating the roles. Here we added a model class "Claims Store" for the claims Why do we have 2 viewmodel classes here? Here we are adding roles to the user. In the video 93 , we are adding claims to the user. For roles we did not add any new model for list the roles , But here we added a new class "ClaimsStore". Why is it so?. Why are we creating 2 viewmodel classes here? .. I would highly appreciate if you could explain as you are the only teacher I have and I am new to it and my background is not computers. Thank you
This piece of code and the one for getting a role are used in multiple places and I wish they can be put into a private function. But I can't find a way to do it... var user = await _userManager.FindByIdAsync(userId); if (user == null) { ViewBag.ErrorMessage = $"User with Id = {userId} cannot be found."; return View("NotFound"); }
I think that might be a job for an injected interface member. Design an interface that has GetUser(), DisplayError() and then implement a class that matches to the functionality you're after. You could also have a method for switching the implementation class at runtime.
It is really a Property? public static List AllClaims = new List() { new Claim("Create Role","Create Role"), new Claim("Edit Role","Edit Role"), new Claim("Delete Role","Delete Role") };
You are very good teacher. Not everyone has the gift of passing knowledge to others. Way to go my friend.
You are the Best RUclips Tech Instructor I have ever met.
Well done.
When did you meet him?
Can't wait for the next video.
Thank you @kudvenkat, any way to store the claims in a table in DataBase? the idea is implement a UI to add,edit, remove the claims like what you did with the roles.
Same problem, I've trying to do that for a while with no luck.
Thank you so much, very resourceful !
Venkat I have question please .. is there any other ways to store claims other than using Static Class "in this demo ClaimsStore" ? and what is the real world projects's way to store claims ? I don't know I feel I understand it but there's something missing
The static class creates these claims that are accessible from anywhere in the namespace. If you wanted to store this on the database you could use the same method done for your employees in AppDbContext.
Excellent! manytks
I had to add: in ManageUserClaimsView.
But in a video it unnecessary!?!
because in HttpGet Action method we write this code:
var model = new UserClaimsViewModel
{
UserId = userId
};
@@nys8260 thanks
@@nys8260 I also written, but didnt work for me, what worked for me is adding hidden field inside the form
This piece of code appears in so many actions methods:
var user = await _userManager.FindByIdAsync(userId);
if (user == null)
{
ViewBag.ErrorMessage = $"Specified user Id {userId} does not exist";
return View("NotFound");
}
I really wish I can put it into its own function. But then the funtion will need to return either a user or a View, which doesn't seem possible?
Thanks Sir
Super explain sir
What if we want to rename a clame in future?
How can we insert into table like claimId and UserId.
if you change your ClaimStore object (add/remove i.e. rename collection items), those changes will be in UI, and when you save it, all existing claims for current user are deleted and new ones added into DB. So effectively it is renaming.
Hi Kudvenkat,
Im here regarding this issue i have just encountered regarding this very tutorial video I am commenting under. I followed your code word by word and yet when i click on update for updating user claims, the http post request does not retrieve the userId value from Url and hence because its null so it redirects me to notfound page. i have dictated my code with yours word to word and there is no difference but somehow the problem is still there. what would you suggest in order to resolve this issue. Anxiously waiting for your response.....
The value of the userId property in the POST action is actually set in GET action. First, check that you have: "UserClaimsViewModel model = new UserClaimsViewModel(){UserId = userId};". If so, the userId parameter in the GET action is probably null. Check that the name of the "userId" paramether in GET action is the same as in EditUser view where you click Manage Claims button. asp-route-userId="@Model.Id".
I dont think you still have this problem, actually I had a doubt regarding this, I asked in the comments section If you know the answer please reply. How I overcome this problem is I set hidden field for UserId inside the from tag and when I click Update, user id is binding to ViewModel UserId prop, so I am able to acces in post action method
I am getting so confusing here. First, Claims are identify the who user is, that dont show what user can do? But bases on your example. user Claims' show what user can do. That are very similar role/permission, a role contains some permissions. Is it right? Claims using by Microsoft is same concept of permission?
Hi - is the misspelling of "Claims" as "Cliams" in the UserClaimsViewModel purposely done?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace EmployeeManagement.ViewModels
{
public class UserClaimsViewModel
{
public UserClaimsViewModel()
{
Cliams = new List();
}
public string UserId { get; set; }
public List Cliams { get; set; }
}
}
What I don't understand, that he is removing the Claims "var result = await userManager.RemoveClaimsAsync(user, userClaims)", than adds the claim ? Why would remove it like this ? Can someone explain ? It's a little bit confusing Thank you. In the past Post operations, he would check if the value is selected.
its like adding a fresh copy to your database of your claims. by removing the claims your database adds a new copy of your claims and replace it with the old one.
Is the source code available anywhere, I don't see a link anywhere
Thank you
wait.. how did the claims get into the database?
Is there any GIT hub link for source code explained in the demo???
Hello Pavan - We do not have a Git hub link, but you can download the source code from the following page.I have also included all the .NET Core tutorial videos, slides and text articles in sequence on this page. Hope you will find it handy.
www.pragimtech.com/courses/asp-net-core-mvc-tutorial-for-beginners/
When you have some time, can you please leave your rating and valuable feedback on the reviews tab. It really helps us. Thank you. Good luck and all the very best with everything you are doing.
@@Csharp-video-tutorialsBlogspot Hi can you please explain me this.
Isn't this similar to adding roles to the user(video 91)?
There we did not add any new model class for stating the roles. Here we added a model class "Claims Store" for the claims
Why do we have 2 viewmodel classes here?
Here we are adding roles to the user. In the video 93 , we are adding claims to the user.
For roles we did not add any new model for list the roles , But here we added a new class "ClaimsStore". Why is it so?.
Why are we creating 2 viewmodel classes here? ..
I would highly appreciate if you could explain as you are the only teacher I have and I am new to it and my background is not computers. Thank you
This piece of code and the one for getting a role are used in multiple places and I wish they can be put into a private function. But I can't find a way to do it...
var user = await _userManager.FindByIdAsync(userId);
if (user == null)
{
ViewBag.ErrorMessage = $"User with Id = {userId} cannot be found.";
return View("NotFound");
}
I think that might be a job for an injected interface member. Design an interface that has GetUser(), DisplayError() and then implement a class that matches to the functionality you're after. You could also have a method for switching the implementation class at runtime.
Why do we need 2 ViewModels for claims sorry I don't get it?
if you are deleting the claims, these should be done in a transaction or unitofwork
Where is the source code for all of this? do you have a github?
1 doubt.
Isn't a vulnerable to show explicitly the UserId in URL?
I meant this.
localhost.com/admin/edituser/845689-58596-484ASD-SDS8777-58AAA
How to use social logins in aso.net core applications
Hello Aamir - We will discuss social logins like Facebook, Google etc in our upcoming videos.
not hash and cant login with new password !!
It is really a Property?
public static List AllClaims = new List()
{
new Claim("Create Role","Create Role"),
new Claim("Edit Role","Edit Role"),
new Claim("Delete Role","Delete Role")
};