dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
34.85k stars 9.84k forks source link

Identity Endpoints - Lifetime IEmailSender #51289

Open augustevn opened 9 months ago

augustevn commented 9 months ago
          > I don't know if this is an issue or not but just want to mention that no matter what _lifetime_ the `IEmailSender` is added by user, It will always be created once.

That is a good point. That's the way I made MapIdentityApi work prior to this PR, but it is different from the Identity UI razor pages. The default no-op implementation is registered as a singleton.

Do you think it's common to need or want services from the request scope? I guess it probably wouldn't hurt. It's just another parameter to pass around.

Originally posted by @halter73 in https://github.com/dotnet/aspnetcore/issues/50301#issuecomment-1696365240


After testing with a few email integrations, I noticed there were scoping issues for working with FluentEmail SMTP.

A custom MailKit SMTP mailer worked fine.

ghost commented 8 months ago

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

Kahbazi commented 8 months ago

@halter73 Do you think this is something that needs to be done in v8.0? If so I can send a PR for this issue.

halter73 commented 8 months ago

It's too late for this kind of change in .NET 8. We'll consider making it a breaking change in .NET 9. In the meantime, you can work around this issue with IHttpContextAccessor and RequestServices or copy IdentityApiEndpointRouteBuilderExtensions which contains MapIdentityApi and resolve the service in a scope yourself. Everything you need should be contained in that single file now that the DTO types are public.