Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed translations for passwordMismatch #14570

Conversation

rasmusmedj
Copy link
Contributor

Fixes #14528

Description

Because of ASP standards, they give us the errorCode "PasswordMismatch" for both changing a password and creating a new one.
Thus we can't have two different translations. This is also why the current translation is misleading when changing password and the current password is a mismatch.

  • Changed translations for passwordMismatch to be less misleading and more generic.

How to test

  • Create a member
  • Create the member with mismatching passwords
  • Assert you get the new translation
  • Change password of the member with mismathcing current password
  • This can be done in a NotificationHandler like:
using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Notifications;
using Umbraco.Cms.Core.Security;

namespace Umbraco.Cms.Web.UI;

public class MyNotificationHandler : INotificationHandler<UmbracoApplicationStartedNotification>
{
    private readonly IMemberManager _memberManager;

    public MyNotificationHandler(IMemberManager memberManager) => _memberManager = memberManager;

    public void Handle(UmbracoApplicationStartedNotification notification)
    {
        var identityMember = _memberManager.FindByIdAsync({YourMemberId}).GetAwaiter().GetResult();
        var resetResult = _memberManager.ChangePasswordAsync(identityMember!, "WrongPassword", "AnyPassword");
    }
}

public class MyComposer : IComposer
{
    public void Compose(IUmbracoBuilder builder) => builder.AddNotificationHandler<UmbracoApplicationStartedNotification, MyNotificationHandler>();
}
  • Assert you get the new translation

@github-actions
Copy link

github-actions bot commented Jul 18, 2023

Hi there @rasmusmedj, thank you for this contribution! 👍

While we wait for one of the Core Collaborators team to have a look at your work, we wanted to let you know about that we have a checklist for some of the things we will consider during review:

  • It's clear what problem this is solving, there's a connected issue or a description of what the changes do and how to test them
  • The automated tests all pass (see "Checks" tab on this PR)
  • The level of security for this contribution is the same or improved
  • The level of performance for this contribution is the same or improved
  • Avoids creating breaking changes; note that behavioral changes might also be perceived as breaking
  • If this is a new feature, Umbraco HQ provided guidance on the implementation beforehand
  • 💡 The contribution looks original and the contributor is presumably allowed to share it

Don't worry if you got something wrong. We like to think of a pull request as the start of a conversation, we're happy to provide guidance on improving your contribution.

If you realize that you might want to make some changes then you can do that by adding new commits to the branch you created for this work and pushing new commits. They should then automatically show up as updates to this pull request.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@georgebid
Copy link
Contributor

Hey @rasmusmedj! Thanks a lot for the PR, someone on the core collaborators team will review this soon 😺

Copy link
Member

@nul800sebastiaan nul800sebastiaan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rasmusmedj I can see the problem, but the new message is not very clear (and I'm not sure mismatch is a word used a lot in Danish). If this needs to change to be generic in all situations it would become a long text, something like: "If this is a new account then the passwords you entered don't match, if you're changing your password then the confirmed password doesn't match the new password". Of course this is not a workable text either.

I would recommend adding another translation key instead and use that in the context, so wherever we use the translation during a Create then use one of them and when we use it during a password change, use the other.

@nul800sebastiaan
Copy link
Member

Since we haven't heard back for a while, I'll close this one. Feel free to start a new PR taking the comments above on board!

@markadrake
Copy link
Contributor

I encountered this issue today.

I received this error message while troubleshooting my change password form for members. In this method call, there is no "confirmation" parameter to compare the "new password" to.

Please reconsider this PR to update this specific language. If you need to make it more generic to handle all cases, that's fine. But as it stands today, it's just wrong.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants