-1

This document says:

We are invoking PasswordSignInAsyncto verify and issue an authentication cookie

Does this method really verify the authenticated cookie? What does it when it does verify, how can i fetch the result of said Verification?

In other words: What is the best method to know that a user is signed in in identity?

chakmeshma
  • 246
  • 8
  • 27

1 Answers1

2

...verify the authenticated cookie

That's not how that sentence is meant to be read, I would assume.

PasswordSignInAsync verifies the credentials that are passed to it, and if they are valid, it creates the authentication cookie and adds it to the response.

...method to know that a user is signed in in identity

The authentication cookie is used to recreate the Identity and Principal objects on each request, so the simple answer to your question is

User.Identity.IsAuthenticated // this is a Boolean value

If you want to stick with the SignInManager, use IsSignedIn(), which would be called like this:

// Assuming you have an instance of SignInManager called _signInManager
_signInManager.IsSignedIn(User);

You probably want to review something like How get current user in asp.net core?

Tieson T.
  • 20,774
  • 6
  • 77
  • 92