From 0ca0af79855209728228f9402dcc6f88452f4edb Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Mon, 5 Nov 2018 16:24:50 +0100 Subject: [PATCH] FIX Do not show TOTPSecret until the member has been initially saved --- src/Extensions/MemberExtension.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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(