Reputation: 13
I installed identity 2.2.1 today. I created my own classes for Role, User, Claim, UserManager, UserRole, EmailService and SmsService. The above classes seem to be working.
I added a new class called SignInManager. I can't seem to fix the error message. I'm getting a convert error message.
public class MySignInManager : SignInManager<MyUser, long>
{
public MySignInManager(MyUserManager userManager, IAuthenticationManager authenticationManager)
: base(userManager, authenticationManager)
{
}
Cannot implicitly convert type 'System.Threading.Tasks.Task' to 'System.Threading.Tasks.Task'
public override Task<MyClaim> CreateUserIdentityAsync(MyUser user)
{
return user.GenerateUserIdentityAsync((MyUserManager)UserManager);
}
This method is okay
public static MySignInManager Create(IdentityFactoryOptions<MySignInManager> options, IOwinContext context)
{
return new MySignInManager(context.GetUserManager<MyUserManager>(), context.Authentication);
}
The user Class looks like this:
public class MyUser : IdentityUser<long, MyLogin, MyUserRole, MyClaim>
{
public string ActivationToken { get; set; }
public string PasswordAnswer { get; set; }
public string PasswordQuestion { get; set; }
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(MyUserManager userManager)
{
var userIdentity = await userManager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
}
Upvotes: 0
Views: 678
Reputation: 13
I changed Task MyClaim to Task ClaimsIdentity to fix the problem.
public override Task<ClaimsIdentity> CreateUserIdentityAsync(PoseyUser user)
{
return user.GenerateUserIdentityAsync((PoseyUserManager)UserManager);
}
Upvotes: 0
Reputation: 107247
The method ends in Async
, which is always a good indication that you need to use async semantics:
public async override Task<MyClaim> CreateUserIdentityAsync(MyUser user)
{
return await user.GenerateUserIdentityAsync((MyUserManager)UserManager);
}
i.e. add async
to the method signature and await
the result
Upvotes: 1