brockallen / BrockAllen.MembershipReboot

MembershipReboot is a user identity management and authentication library.
Other
742 stars 238 forks source link

Change Email Event Added but Never Raised #587

Closed strizzaflex closed 8 years ago

strizzaflex commented 8 years ago

I'm working with MR 8.1.0

I'm calling _accountService.ChangeEmailRequest(user.ID, model.EmailAddress); in my controller.

I can see that the following lines are called in AccountService

 this.AddEvent(new EmailChangeRequestedEvent<TAccount> { Account = account, OldEmail = oldEmail, NewEmail = newEmail, VerificationKey = key });
 UpdateInternal(account);

I can see that the database is being updated with the correct Verification information. But the email is never sent. I have checked the email smtp bits are working with:

     var delivery = new SmtpMessageDelivery();
            delivery.Send(new Message
            {
                Body = "TEST",
                To = "foo@gmail.com",
                Subject = "TestSubject"
            });

I can not figure out what is going wrong here. I must have missed a setup step somewhere. Do I need to setup the EventBus somewhere?

Here is my Reboot config:

    public static class MRConfig
    {
        public static readonly MembershipRebootConfiguration<CustomUser> Config;
        static MRConfig()
        {
            Config = new MembershipRebootConfiguration<CustomUser>
            {
                PasswordHashingIterationCount = 10000,
                RequireAccountVerification = true,
                MultiTenant = true,
                DefaultTenant = "autosoft",
                UsernamesUniqueAcrossTenants = false
            };

            var appInfo = new ApplicationInformation
            {
                ApplicationName = "Foo",
                EmailSignature = "Test Signature",
                ConfirmChangeEmailUrl = "user/ChangeEmail/Confirm/",
                ConfirmPasswordResetUrl = "user/PasswordReset/Confirm/",
                CancelVerificationUrl = "user/Cancel/",
                LoginUrl = "user/login/"

            };

            var formatter = new EmailMessageFormatter<CustomUser>(appInfo);
            Config.AddEventHandler(new EmailAccountEventsHandler<CustomUser>(formatter));
        }
    }
strizzaflex commented 8 years ago

OK. So this website was "setup" before I got into it and it looks like in the end the issue was there wasn't a proper dependency injection system setup so things were being newed up and I assume that means the events were getting added and then blown away before they could send. I took a look into the samples and setup our ninject container based on the autofac stuff. Seems to be working now.

So I guess if that helps someone good. This can be deleted or closed or whatever.