How can I assign the ‘EmailService’ property on the UserManager to the ‘EmailService’ class Can I extend the UserManager : AbpUserManager<Tenant, Role, User> in IdentityConfig?
ex: /***************************************/ public class ApplicationRoleManager : RoleManager<IdentityRole> { public ApplicationRoleManager(IRoleStore<IdentityRole,string> roleStore) : base(roleStore) { }
public static ApplicationRoleManager Create(IdentityFactoryOptions<ApplicationRoleManager> options, IOwinContext context)
{
return new ApplicationRoleManager(new RoleStore<IdentityRole>(context.Get<ApplicationDbContext>()));
}
}
public class EmailService : IIdentityMessageService
/***********************************/
4 Answer(s)
-
0
How... I did not understand your question. Are you using "mudule zero" template? If so, there is already a UserManager class in the solution. But did not understand "How can I assign the ‘EmailService’ property on the UserManager to the ‘EmailService’ class".
-
0
Yes, Im using "mudule zero" template :), and there is already a UserManager class in the solution. I need Send email by UserManager.SendEmailAsync, and implment this code:
public class EmailService : IIdentityMessageService { public Task SendAsync(IdentityMessage message) { // Plug in your email service here to send an email. return configSendGridasync(message); //return Task.FromResult(0); }
-
0
I customs Email Service and integrated with external email provider Sendgrid, and assign class "EmailService" to EmailService property via UserManager constructor
As UserManager constructor:
this.EmailService = new EmailService(); this.SmsService = new SmsService();
and Create Classes
-
public class EmailService : IIdentityMessageService { public Task SendAsync(IdentityMessage message)
-
public class SmsService : IIdentityMessageService { public Task SendAsync(IdentityMessage message)
But NO hit :(
-
-
0
Don't use "new", we are using dependency injection (DI) (<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Dependency-Injection">http://www.aspnetboilerplate.com/Pages/ ... -Injection</a>). So, register your emailservice to DI and inject into UserManager.