Skip to content

Commit e3a54cf

Browse files
committed
Merge branch 'pu/ps/matrixAcc404' into 'main'
fix(MatrixSynapseIntegrator/Frontend): make getAccountData work without MANAGE_ACCOUNTS right See merge request tine20/tine20!7170
2 parents 467f39e + 6f0b9a5 commit e3a54cf

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

tests/tine20/MatrixSynapseIntegrator/Frontend/JsonTest.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,20 @@ public function testMatrixAccountApi($delete = true): array
3838

3939
public function testGetAccountData()
4040
{
41-
$account = $this->testMatrixAccountApi(false);
42-
// self::assertArrayHasKey(MatrixSynapseIntegrator_Model_MatrixAccount::FLD_MATRIX_RECOVERY_PASSWORD,
43-
// $account, print_r($account, true));
41+
$this->testMatrixAccountApi(false);
4442
$accountData = $this->_getUit()->getAccountData();
4543
self::assertIsArray($accountData);
4644
self::assertEquals('somepw', $accountData['recovery_password']);
4745
}
46+
47+
public function testMissingGetAccountData()
48+
{
49+
Tinebase_Core::setUser($this->_personas['sclever']);
50+
try {
51+
$this->_getUit()->getAccountData();
52+
self::fail('should throw 404 exception');
53+
} catch (Tinebase_Exception_NotFound $tenf) {
54+
self::assertEquals('No Matrix Account found', $tenf->getMessage());
55+
}
56+
}
4857
}

tine20/MatrixSynapseIntegrator/Controller/MatrixAccount.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,12 @@ protected function __construct()
5353
*/
5454
public function checkFilterACL(Tinebase_Model_Filter_FilterGroup $_filter, $_action = self::ACTION_GET)
5555
{
56-
if (!$this->_doContainerACLChecks || $this->checkRight(Admin_Acl_Rights::MANAGE_ACCOUNTS)) {
56+
if (!$this->_doRightChecks
57+
|| !$this->_doContainerACLChecks
58+
|| $this->checkRight(Admin_Acl_Rights::MANAGE_ACCOUNTS)
59+
) {
5760
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__
58-
. ' Container ACL disabled for ' . $_filter->getModelName() . '.');
61+
. ' ACL / right checks disabled for ' . $_filter->getModelName() . '.');
5962
return;
6063
}
6164

@@ -75,6 +78,10 @@ public function checkFilterACL(Tinebase_Model_Filter_FilterGroup $_filter, $_act
7578
*/
7679
protected function _checkRight($_action)
7780
{
81+
if (! $this->_doRightChecks) {
82+
return;
83+
}
84+
7885
switch ($_action) {
7986
case 'get':
8087
$this->checkRight(Admin_Acl_Rights::MANAGE_ACCOUNTS);
@@ -98,13 +105,15 @@ protected function _getApplicationRightsClass(): string
98105

99106
public function getMatrixAccountForCurrentUser(): MatrixSynapseIntegrator_Model_MatrixAccount
100107
{
108+
$check = $this->doRightChecks(false);
101109
/** @var ?MatrixSynapseIntegrator_Model_MatrixAccount $result */
102110
$result = $this->search(Tinebase_Model_Filter_FilterGroup::getFilterForModel(
103111
MatrixSynapseIntegrator_Model_MatrixAccount::class, [[
104112
Tinebase_Model_Filter_Abstract::FIELD => MatrixSynapseIntegrator_Model_MatrixAccount::FLD_ACCOUNT_ID,
105113
Tinebase_Model_Filter_Abstract::VALUE => Tinebase_Core::getUser()->getId()
106114
]]
107115
))->getFirstRecord();
116+
$this->doRightChecks($check);
108117
if (!$result) {
109118
throw new Tinebase_Exception_NotFound('No Matrix Account found');
110119
}

0 commit comments

Comments
 (0)