diff --git a/src/Extensions/MemberExtension.php b/src/Extensions/MemberExtension.php index d99190f..6228d6d 100644 --- a/src/Extensions/MemberExtension.php +++ b/src/Extensions/MemberExtension.php @@ -25,7 +25,7 @@ class MemberExtension extends DataExtension * @var array */ private static $db = [ - 'TOTPSecret' => 'Varchar(1024)' + 'TOTPSecret' => 'Varchar(1024)', ]; /** @@ -48,6 +48,10 @@ public function onBeforeWrite() */ public function updateCMSFields(FieldList $fields) { + if (!$this->owner->exists()) { + $fields->removeByName('TOTPSecret'); + } + if (strlen($this->owner->TOTPSecret)) { $qrcodeURI = $this->GoogleAuthenticatorQRCode(); $fields->addFieldToTab('Root.Main', ToggleCompositeField::create(