Skip to content

Add reset password support to identity endpoints #47231

@halter73

Description

@halter73

Background and Motivation

Add email confirmation and reset password support to identity endpoints.

Proposed API

// Microsoft.Extensions.Identity.Core.dll

// This namespace and interface already exist in Microsoft.AspNetCore.Identity.UI.dll
// but is new in Microsoft.Extensions.Identity.Core.dll
+ namespace Microsoft.AspNetCore.Identity.UI.Services;

+ public interface IEmailSender
+ {
+    Task SendEmailAsync(string email, string subject, string htmlMessage);
+ }

// Used so that Identity UI's unconfigured email sender logic works the same way regardless of whether
// it was added by AddApiEndpoints or AddDefaultUI
+ public sealed class NoOpEmailSender : IEmailSender
+ {
+    public Task SendEmailAsync(string email, string subject, string htmlMessage) => Task.CompletedTask;
+ }

// Microsoft.AspNetCore.Identity.UI.dll
+ [assembly: TypeForwardedTo(typeof(IEmailSender))]

Usage Examples

https://www.twilio.com/blog/how-to-send-asp-net-core-identity-emails-with-twilio-sendgrid

Alternative Designs

Create a new duplicate interface in a better namespace like just Microsoft.AspNetCore.Identity. Possibly use different methods for different kind of emails. E.g. SendConfirmationEmail, SendPasswordResetEmail, etc... Maybe this could be parameterized by TUser.

Risks

If people wanted to use Identity UI and Identity API endpoints in the same app with different email senders. This could make that hard or impossible to do.

Metadata

Metadata

Assignees

Labels

Priority:0Work that we can't release withoutapi-approvedAPI was approved in API review, it can be implementedarea-identityIncludes: Identity and providersenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-token-identity

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions