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

FIX re-label forgot password for uniq id #11568

Open
wants to merge 1 commit into
base: 6
Choose a base branch
from

Conversation

andrewandante
Copy link
Contributor

@andrewandante andrewandante commented Jan 20, 2025

Description

Adds a new lang option and a decent default for non-Email unique identifier fields.

Manual testing steps

Set unique_identifier_field to something non-email.
See that it changes the field label.
See that you can change the field label via an app en.yml

Issues

Fixes #11567

Pull request checklist

  • The target branch is correct
  • All commits are relevant to the purpose of the PR (e.g. no debug statements, unrelated refactoring, or arbitrary linting)
    • Small amounts of additional linting are usually okay, but if it makes it hard to concentrate on the relevant changes, ask for the unrelated changes to be reverted, and submitted as a separate PR.
  • The commit messages follow our commit message guidelines
  • The PR follows our contribution guidelines
  • Code changes follow our coding conventions
  • This change is covered with tests (or tests aren't necessary for this change)
  • Any relevant User Help/Developer documentation is updated; for impactful changes, information is added to the changelog for the intended release
  • CI is green

@andrewandante andrewandante force-pushed the FIX_lost_password_for_non_email branch 2 times, most recently from e2853d9 to c5843c9 Compare January 20, 2025 20:57
@andrewandante andrewandante marked this pull request as ready for review January 20, 2025 22:56
src/Security/MemberAuthenticator/LostPasswordForm.php Outdated Show resolved Hide resolved
Comment on lines 28 to 35
$uniqueIdentifier = Member::config()->get('unique_identifier_field');
if ($uniqueIdentifier === 'Email') {
$emailField = EmailField::create('Email', _t('SilverStripe\\Security\\Member.EMAIL', 'Email'));
} else {
// This field needs to still be called Email, but we can re-label it
$emailField = TextField::create('Email', _t('SilverStripe\\Security\\Member.LOSTPASSWORDLABEL', $uniqueIdentifier));
}
Copy link
Member

Choose a reason for hiding this comment

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

Might be worth getting a member singleton and calling $singleton->fieldLabel($uniqueIdentifier) to get the field label. Then we don't need any branching logic at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good trick! Still need to split on fieldtype though I think, the email validation on the email field still seems valuable.

@GuySartorelli GuySartorelli self-assigned this Jan 21, 2025
@andrewandante andrewandante force-pushed the FIX_lost_password_for_non_email branch from c5843c9 to 7e5eeb2 Compare January 22, 2025 04:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants