Where is Microsoft.AspNet.Identity.Owin.AuthenticationManager in Asp.Net Identity RTM version?

I have installed the nightly build of the AspNet-identity assemblies from here

It seems that the AuthenticationManager class from the RC version is gone from the RTM version (Microsoft.AspNet.Identity.Owin.1.0.0-rtm-130914).

It used to be in the Microsoft.AspNet.Identity.Owin assembly, but its no longer there.

This class had the methods: SignInAsync and CheckPasswordAndSignInAsync that are used in the default project you get when creating new ASP.Net web application MVC project with Individual User Account authentication.

Where is the AuthenticationManager now? Or what to use instead?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

That class is gone, as it was basically just adding methods that generated a ClaimsIdentity and passed that into an Owin.Security.IAuthenticationManager.

Instead the RTM templates have a SignIn method in the controller that looks something like this:

    private async Task SignInAsync(ApplicationUser user, bool isPersistent) {
        AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
        var identity = await UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
        AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);
    }

Method 2

By all means someone correct me if I’m wrong but hasn’t the AuthenticationManager been moved to

HttpContext.Current.GetOwinContext().Authentication?

and so the above example now goes:

private async Task SignInAsync(UserManager<User> manager, User user, bool isPersistent)
{
    var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
    authenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
    var identity = await manager.CreateIdentityAsync(user, DeffaultAuthenticationTypes.ApplicationCookie);
    authenticationManager.SignIn(new AuthenticationProperties(){ IsPersistent = isPersistent }, identity);
}

Note that UserManager no longer seems to have the static method CreateIdentityAsync so this has to be fired off an object instance.

Unless I’ve missed something?


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x