User-557362475 posted
I haven't found a clear answer for this after searching but why do all the stackover flow answers to OWIN OAuth question say to set the
<authentication mode="Forms">
and then to
<modules runAllManagedModulesForAllRequests="true"> <!--added-->
<remove name="FormsAuthentication" />
<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" /> <!--added-->
</modules>
I'm following this tutorial:
http://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on
but they never show that they have successfully login using OWIN, while I get an error for Request.IsAuthenticated = false in the _loginpartial.cshtml page.
The AccountController's ExternLoginCallBack works fine, and shows Success, but then the webApp still doesn't show the user is authenticated.
public async Task<ActionResult> ExternalLoginCallback(string returnUrl)
{
var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
if (loginInfo == null)
{
return RedirectToAction("Login");
}
// Sign in the user with this external login provider if the user already has a login
var result = await SignInManager.ExternalSignInAsync(loginInfo, isPersistent: true);
switch (result)
{
case SignInStatus.Success:
return RedirectToLocal(returnUrl);
case SignInStatus.LockedOut:
return View("Lockout");
case SignInStatus.RequiresVerification:
return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = false });
case SignInStatus.Failure:
default:
// If the user does not have an account, then prompt the user to create an account
ViewBag.ReturnUrl = returnUrl;
ViewBag.LoginProvider = loginInfo.Login.LoginProvider;
return View("ExternalLoginConfirmation", new ExternalLoginConfirmationViewModel { Email = loginInfo.Email });
}
}
Any thoughts? Do we really need to set the Authentication mode to forms if we're using OWIN?
Original question here:
http://stackoverflow.com/questions/35118698/asp-net-4-5-mvc-5-owin-and-forms-authentication