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: incorrect created date shown on backup method #572

Open
wants to merge 4 commits into
base: 5
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/FormField/RegisteredMFAMethodListField.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ public function getSchemaDataDefaults()
],
// We need all available methods so we can re-register pre-existing methods
'allAvailableMethods' => $generator->getAvailableMethods(),
'backupCreationDate' => $this->getBackupMethod()
? $this->getBackupMethod()->Created
'backupCreatedDate' => $this->getBackupMethod($member)
? $this->getBackupMethod($member)->Created
: null,
'resetEndpoint' => SecurityAdmin::singleton()->Link("users/reset/{$this->value}"),
'isMFARequired' => EnforcementManager::create()->isMFARequired(),
Expand All @@ -70,11 +70,12 @@ public function getSchemaDataDefaults()
/**
* Get the registered backup method (if any) from the currently logged in user.
*
* @param Member $member
* @return RegisteredMethod|null
*/
protected function getBackupMethod(): ?RegisteredMethod
protected function getBackupMethod(Member $member): ?RegisteredMethod
Copy link
Member

Choose a reason for hiding this comment

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

We can't add properties to protected methods in a minor release, as that's a violation of our public API. This change would need to happen in a major release.

Is there a way you can fix this bug without modifying the existing API method signatures?

Copy link
Author

Choose a reason for hiding this comment

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

@GuySartorelli I'm now storing Member in a private property and reverted the method signature back to the original. Let me know if that's ok.

{
$backupMethod = MethodRegistry::singleton()->getBackupMethod();
return RegisteredMethodManager::singleton()->getFromMember(Security::getCurrentUser(), $backupMethod);
return RegisteredMethodManager::singleton()->getFromMember($member, $backupMethod);
}
}