Skip to content

Commit

Permalink
Updated code for getting current user
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-nzl committed May 22, 2024
1 parent a2541b4 commit e0108af
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Cms/DMSDocumentAddController.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use SilverStripe\Assets\File;
use SilverStripe\Security\Member;
use SilverStripe\Security\Permission;
use SilverStripe\Security\Security;
use SilverStripe\Admin\LeftAndMain;

/**
Expand Down Expand Up @@ -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 (
Expand Down
3 changes: 2 additions & 1 deletion src/Model/DMSDocumentSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = (
Expand Down
3 changes: 2 additions & 1 deletion tests/DMSDocumentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -263,7 +264,7 @@ public function testCanCreate()
*/
protected function logoutMember()
{
if ($member = Member::currentUser()) {
if ($member = Security::getCurrentUser()) {
$member->logOut();
}
}
Expand Down

0 comments on commit e0108af

Please sign in to comment.