Asp.net Mvc 6 receives user requests immediately after logging in

On the Asp.net Mvc 6 website, I set up a ready-made AccountController to add a custom request before calling userManager.CreateAsync() , as when registering

  • with a local account (email / password) in the controller's Register() method
  • with an external provider (google / facebook), in the ExternalLoginConfirmation() controller

Now, what I would like to do, right after the user logs in,

  • in the Login() method after calling signInManager.PasswordSignInAsync() and
  • in ExternalLoginCallback() after calling signInManager.ExternalLoginSignInAsync()

... to get this application, ideally, without getting into the database to get the user.

I noticed that if I look at the user immediately after logging in, the Claims collection is empty. However, if I look at this in the next controller action, the Claims collection will be populated and contain my own requirements.

The question is why the Claims are not filled immediately after logging in (I assume that the login code does not update CurrentPrincipal?), And is there another place to check immediately after logging in to receive claims without getting into the database?

+5
source share
1 answer

You can try to implement your own ApplicationUserStore and populate all the properties of the user (or the object that is used as the authentication object) that you need.

0
source

Source: https://habr.com/ru/post/1236972/


All Articles