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 2 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
12 changes: 8 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,15 @@ public function getSchemaDataDefaults()
/**
* Get the registered backup method (if any) from the currently logged in user.
*
* @param Member|null $member
* @return RegisteredMethod|null
*/
protected function getBackupMethod(): ?RegisteredMethod
protected function getBackupMethod(Member $member = null): ?RegisteredMethod
gavynj marked this conversation as resolved.
Show resolved Hide resolved
{
$backupMethod = MethodRegistry::singleton()->getBackupMethod();
return RegisteredMethodManager::singleton()->getFromMember(Security::getCurrentUser(), $backupMethod);
return RegisteredMethodManager::singleton()->getFromMember(
$member ?? Security::getCurrentUser(),
$backupMethod
);
}
}