From e0108af9525d29530c7e665eef3efc08971b6b03 Mon Sep 17 00:00:00 2001 From: "jack.conner" Date: Wed, 22 May 2024 14:54:14 +1200 Subject: [PATCH] Updated code for getting current user --- src/Cms/DMSDocumentAddController.php | 3 ++- src/Model/DMSDocumentSet.php | 3 ++- tests/DMSDocumentTest.php | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Cms/DMSDocumentAddController.php b/src/Cms/DMSDocumentAddController.php index e89ce7f..1aced8a 100644 --- a/src/Cms/DMSDocumentAddController.php +++ b/src/Cms/DMSDocumentAddController.php @@ -21,6 +21,7 @@ use SilverStripe\Assets\File; use SilverStripe\Security\Member; use SilverStripe\Security\Permission; +use SilverStripe\Security\Security; use SilverStripe\Admin\LeftAndMain; /** @@ -365,7 +366,7 @@ public function getAllowedExtensions() public function canView($member = null, $context = []) { if (!$member || !(is_a($member, Member::class)) || is_numeric($member)) { - $member = Member::currentUser(); + $member = Security::getCurrentUser(); } if ( diff --git a/src/Model/DMSDocumentSet.php b/src/Model/DMSDocumentSet.php index e37d791..7d2fe8f 100644 --- a/src/Model/DMSDocumentSet.php +++ b/src/Model/DMSDocumentSet.php @@ -8,6 +8,7 @@ use SilverStripe\ORM\DataList; use SilverStripe\Security\Permission; use SilverStripe\ORM\DataObject; +use SilverStripe\Security\Security; /** * A document set is attached to Pages, and contains many DMSDocuments @@ -147,7 +148,7 @@ public function canDelete($member = null, $context = []) public function getGlobalPermission(Member $member = null) { if (!$member || !(is_a($member, Member::class)) || is_numeric($member)) { - $member = Member::currentUser(); + $member = Security::getCurrentUser(); } $result = ( diff --git a/tests/DMSDocumentTest.php b/tests/DMSDocumentTest.php index 55b3d65..4caa073 100644 --- a/tests/DMSDocumentTest.php +++ b/tests/DMSDocumentTest.php @@ -10,6 +10,7 @@ use SilverStripe\Control\HTTPRequest; use SilverStripe\Forms\CompositeField; use SilverStripe\Security\Member; +use SilverStripe\Security\Security; use Sunnysideup\DMS\DMS; use SilverStripe\Dev\SapphireTest; @@ -263,7 +264,7 @@ public function testCanCreate() */ protected function logoutMember() { - if ($member = Member::currentUser()) { + if ($member = Security::getCurrentUser()) { $member->logOut(); } }