CleanArchitectureWithBlazorServer icon indicating copy to clipboard operation
CleanArchitectureWithBlazorServer copied to clipboard

Register confirmation is not working

Open Alywan opened this issue 1 year ago • 6 comments

We do not receive any registration confirmation when registering a new user. Is this related to the fact that you deleted the [IdentityNoOpEmailSender.cs] file ?

Alywan avatar Jul 25 '24 07:07 Alywan

image Don't forget to configure these parameters for your SMTP server.

neozhu avatar Jul 25 '24 09:07 neozhu

It's configured correctly, other e-mails are working fine. In my case : the register confirmation e-mail is not sent via e-mail.

I have to go with the Admin account, set the new registered user as "Active", and then, he will get the e-mail to reset the password. After that, though, he cannot login, because in the database the "EmailConfirmed" value is 0.

btw, why do i have to setup a password at signup, and after that, when the user gets the confirmation e-mail, he has to reset the password again ?

Alywan avatar Jul 25 '24 11:07 Alywan

Btw, this is the error message we get : [14:08:35 ERR ] Failed to send templated email. Subject: Account Activation Required, Template: _useractivation. An exception occurred. System.ObjectDisposedException: Cannot access a disposed object. Object name: 'IServiceProvider'. at Microsoft.Extensions.DependencyInjection.ServiceLookup.ThrowHelper.ThrowObjectDisposedException() at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider) at Microsoft.Extensions.DependencyInjection.FluentEmailServiceCollectionExtensions.<>c__DisplayClass0_0.<AddFluentEmail>b__0(IServiceProvider x) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor2.VisitCallSite(ServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass2_0.<RealizeService>b__0(ServiceProviderEngineScope scope) at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(ServiceIdentifier serviceIdentifier, ServiceProviderEngineScope serviceProviderEngineScope) at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider) at FluentEmail.Core.FluentEmailFactory.Create() at PropertyManagement.Infrastructure.Services.MailService.SendAsync(String to, String subject, String template, Object model) in D:\Dev\xxx\src\Infrastructure\Services\MailService.cs:line 71 at PropertyManagement.Application.Features.Identity.Notifications.UserActivation.UserActivationNotificationHandler.Handle(UserActivationNotification notification, CancellationToken cancellationToken) in D:\Dev\xxx\src\Application\Features\Identity\Notifications\UserActivationCommand.cs:line 29

Alywan avatar Jul 25 '24 11:07 Alywan

Can you debug and fix this error? also you can check the email template file in the folder \Resources\EmailTemplates_authenticatorcode.cshtml

neozhu avatar Jul 25 '24 12:07 neozhu

Can you debug and fix this error?

also you can check the email template file in the folder \Resources\EmailTemplates_authenticatorcode.cshtml

Looks like the dependency container already disposes the service before the service is needed. I would have tried to fix this myself, but I'm currently on vacation to Japan for 3 weeks 😅

Bram1903 avatar Jul 26 '24 07:07 Bram1903

Can you debug and fix this error? also you can check the email template file in the folder \Resources\EmailTemplates_authenticatorcode.cshtml

Hard to debug... I have all the files in the correct place.

At this line of code in my MailService i get that error :

        else
        {
            return _fluentEmailFactory
                .Create()
                .To(to)
                .Subject(subject)
                .UsingTemplateFromEmbedded(string.Format(TemplatePath, template), model, Assembly.GetEntryAssembly())
                .SendAsync();
        }

Alywan avatar Jul 26 '24 09:07 Alywan