umbraco / Umbraco-CMS

Umbraco is a free and open source .NET content management system helping you deliver delightful digital experiences.
https://umbraco.com
MIT License
4.4k stars 2.66k forks source link

Unable to allow duplicate email addresses for member with RequireUniqueEmail = false #15676

Open pjs92 opened 7 months ago

pjs92 commented 7 months ago

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

10.8.3

Bug summary

I've migrated an Umbraco site from v7.15.4 to v10.8.3 and have noticed that it's no longer possible to create multiple members with the same email address.

In v7, we were able to set RequireUniqueEmail = false to the UmbracoMembershipProvider in the web.config and set false in the umbracoSettings.config. This allowed us to create multiple members with the same email address but still have unique usernames.

In v10, I can see we can set the UsernameIsEmail to false in the Security settings in appSettings.json however I can't see a way to not require unique email addresses. Is there a way to configure the member identity options so that duplicate emails are ignored?

Specifics

I had tried configuring the identity options in the Startup.cs to set RequireUniqueEmail to false however this doesn't seem to take effect.

services.Configure<IdentityOptions>(options =>
{
    options.User.RequireUniqueEmail = false;
});

It looks like the RequireUniqueEmail is getting set to true in the ConfigureMemberIdentityOptions.

It also looks like the MemberSaveModelValidator has validation in place that requires members that are being saved to always have a unique email address.

Steps to reproduce

Expected result / actual result

By setting RequireUniqueEmail to false for the IdentityOptions, I'd expect to be able save members without needing them to have unique email addresses however they all throw a validation error requiring a unique email address

github-actions[bot] commented 7 months ago

Hi there @pjs92!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot :robot: :slightly_smiling_face:

Zeegaan commented 7 months ago

Theres apparently a IPostConfigureOptions that will ensure it runs after the ConfigureMemberIdentityOptions, could you try something like this instead ? 😁

public sealed class MyConfigureMemberIdentityOptions : IPostConfigureOptions<IdentityOptions>
{
    public void PostConfigure(string? name, IdentityOptions options)
    {
        options.User.RequireUniqueEmail = false;
    }
}
Zeegaan commented 7 months ago

I see there's also a PR in the making duplicate emails possible 😁 https://github.com/umbraco/Umbraco-CMS/pull/14784