Hmm, that is what I was doing (but inline). Perhaps my logic is in the code that determines whether you are logged in. Does this look right?
var loggedInUser = Context.GetOwinContext().Authentication.User;
bool bIsAuthenticated = false;
string userName = "";
if (loggedInUser != null)
{
bIsAuthenticated = loggedInUser.Identity.IsAuthenticated;
userName = loggedInUser.Identity.Name;
}
bool bIsLoggedin = Members.IsLoggedIn(); // Old way without OWIN/Identity extensions
The bIsAuthenticated results in false, and the userName is not set either... additionally, the old way does also not realize that the user is logged in.
UmbracoIdentity - How do you programatically login a member?
I've looked through the package's code, and cannot seem to piece together what is needed to do this.
If I have the IMember object, how does one programmatically log the member in so that all downstream code and pages carry the authenticated member?
You use the MembershipHelper to log in a member, passing it the username and password of the member logging in.
Members.Login(username, password)
I dont have the username and password.
So how do you know they are a valid member?
So how do you know they are a valid member?
External Authentication
You need to write a formsauthentication cookie, but you will still need a username to do that, so you will need to get that using your imember object
Check https://github.com/Shazwazza/UmbracoIdentity/blob/e5af79578de92aa335ba5dbfb594ba9f6ad9173e/src/UmbracoIdentity.Web/App_Start/Controllers/UmbracoIdentityAccountController.cs#L74 , loginInfo contains the username.
Depending on the type of external authentication, the username can be returned in loginInfo.DefaultUserName or in loginInfo.Login.ProviderKey
We do this:
Hmm, that is what I was doing (but inline). Perhaps my logic is in the code that determines whether you are logged in. Does this look right?
The bIsAuthenticated results in false, and the userName is not set either... additionally, the old way does also not realize that the user is logged in.
Try
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.