Manage user claims in asp net core

Поделиться
HTML-код
  • Опубликовано: 2 фев 2025

Комментарии • 46

  • @7Andy77
    @7Andy77 4 года назад +2

    You are very good teacher. Not everyone has the gift of passing knowledge to others. Way to go my friend.

  • @ddanhero
    @ddanhero 5 лет назад +9

    You are the Best RUclips Tech Instructor I have ever met.
    Well done.

  • @imikhan83
    @imikhan83 5 лет назад

    Can't wait for the next video.

  • @husam-ebish
    @husam-ebish 5 лет назад +3

    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.

    • @Zetsubou_
      @Zetsubou_ 4 года назад

      Same problem, I've trying to do that for a while with no luck.

  • @tondar2127
    @tondar2127 4 года назад

    Thank you so much, very resourceful !

  • @m.e858
    @m.e858 5 лет назад +1

    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

    • @donoboyle8718
      @donoboyle8718 5 лет назад +2

      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.

  • @laurolnunes
    @laurolnunes 4 года назад

    Excellent! manytks

  • @lordjim9971
    @lordjim9971 5 лет назад +3

    I had to add: in ManageUserClaimsView.
    But in a video it unnecessary!?!

    • @nys8260
      @nys8260 4 года назад +2

      because in HttpGet Action method we write this code:
      var model = new UserClaimsViewModel
      {
      UserId = userId
      };

    • @lordjim9971
      @lordjim9971 4 года назад

      @@nys8260 thanks

    • @hussainmdyt7638
      @hussainmdyt7638 2 года назад

      @@nys8260 I also written, but didnt work for me, what worked for me is adding hidden field inside the form

  • @conaxlearn8566
    @conaxlearn8566 4 года назад

    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?

  • @codingislife6387
    @codingislife6387 Год назад

    Thanks Sir

  • @sakthivel-lc9ni
    @sakthivel-lc9ni 5 лет назад

    Super explain sir

  • @abidalisidd
    @abidalisidd 5 лет назад +1

    What if we want to rename a clame in future?
    How can we insert into table like claimId and UserId.

    • @basilio100
      @basilio100 4 года назад +1

      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.

  • @muhammadwaqasiqbal8243
    @muhammadwaqasiqbal8243 4 года назад

    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.....

    • @kesiu90
      @kesiu90 4 года назад

      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".

    • @hussainmdyt7638
      @hussainmdyt7638 2 года назад

      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

  • @HuyTran-gf6ye
    @HuyTran-gf6ye 4 года назад

    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?

  • @KenKraska
    @KenKraska 3 года назад

    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; }
    }
    }

  • @nolimitsREAL
    @nolimitsREAL 4 года назад

    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.

    • @muhammadwaqasiqbal8243
      @muhammadwaqasiqbal8243 4 года назад

      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.

  • @mbahojlo
    @mbahojlo 2 года назад

    Is the source code available anywhere, I don't see a link anywhere

  • @Sam-yb9ut
    @Sam-yb9ut 4 года назад

    Thank you

  • @his-worddevotionals540
    @his-worddevotionals540 2 года назад

    wait.. how did the claims get into the database?

  • @jpavankumarmuddana3887
    @jpavankumarmuddana3887 5 лет назад

    Is there any GIT hub link for source code explained in the demo???

    • @Csharp-video-tutorialsBlogspot
      @Csharp-video-tutorialsBlogspot  5 лет назад +1

      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.

    • @lifetraveler8008
      @lifetraveler8008 4 года назад

      ​@@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

  • @conaxlearn8566
    @conaxlearn8566 4 года назад +1

    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");
    }

    • @nickeax
      @nickeax 4 года назад

      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.

  • @hossammetwally07
    @hossammetwally07 5 лет назад

    Why do we need 2 ViewModels for claims sorry I don't get it?

  • @jkmalify
    @jkmalify 2 года назад +1

    if you are deleting the claims, these should be done in a transaction or unitofwork

  • @TopGearScooter
    @TopGearScooter 2 года назад

    Where is the source code for all of this? do you have a github?

  • @thirumanitheivarajan7295
    @thirumanitheivarajan7295 4 года назад

    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

  • @mhraamirali
    @mhraamirali 5 лет назад

    How to use social logins in aso.net core applications

  • @waseemkhalid7641
    @waseemkhalid7641 4 года назад

    not hash and cant login with new password !!

  • @zorigdavaag.8354
    @zorigdavaag.8354 4 года назад

    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")
    };