Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Add custom claim to ClaimsIdentity #3605


User avatar
0
PhilWynn created

Hi,

I need to add a custom claim on login. All example code I have seen assumes that we extend AccountController.SignInAsync in order to do this. However, the current version now uses SignInManager.SignInOrTwoFactor.

Could you please tell me how I can now insert a custom claim on login.

Thank you.


9 Answer(s)
  • User Avatar
    0
    bbakermmc created

    You and bunch of other people are still waiting for a reply on this :)

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @BBakerMMC,

    Sorry for the delay. It will be ready tomorrow.

    Thanks.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    I have created a new gist for this, you can check it out here <a class="postlink" href="https://gist.github.com/ismcagdas/6f2a9a3b5d7b907cb8d94a72124d59a1">https://gist.github.com/ismcagdas/6f2a9 ... 72124d59a1</a>.

    Thanks.

  • User Avatar
    0
    PhilWynn created

    Thank you.

  • User Avatar
    0
    alper created
    Support Team

    thanks for your feedback

  • User Avatar
    0
    PhilWynn created

    Apologies, but I have just realised that the example given is for Core. Would you please be able to give an example of how this could be achieved in MVC5.

    Thank you.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @PhilWynn,

    Yes, it is for ASP.NET Core, we will prepare one for MVC 5.x in a short time.

  • User Avatar
    0
    PhilWynn created

    Thank you.

    I have another related issue. I am using the method you propose to save data against a user session. The problem I am now getting is that many of my unit tests, that rely on this data, are now failing. How can I inject this new session data into the unit tests?

    Many thanks

  • User Avatar
    0
    felixbeltran created

    Hi,

    I could also use the MVC 5 example. Any news on this?

    Thanks.