Skip to content

Commit 369c95f

Browse files
committed
fixed admin detection on server side, incremented the version number
1 parent 0545c44 commit 369c95f

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<name>Time Tracker</name>
66
<summary>Time Tracker App</summary>
77
<description><![CDATA[Time Tracker App]]></description>
8-
<version>0.0.17</version>
8+
<version>0.0.18</version>
99
<licence>agpl</licence>
1010
<author mail="[email protected]" >MTier Ltd.</author>
1111
<namespace>TimeTracker</namespace>

lib/Controller/AjaxController.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ public function workIntervals() {
111111
}
112112

113113

114+
public function isAdminUser(){
115+
return \OC_User::isAdminUser(\OC_User::getUser());
116+
}
117+
114118
/**
115119
*
116120
* @NoAdminRequired
@@ -366,7 +370,7 @@ public function addProject($name) {
366370
$p->setClientId($clientId);
367371
$this->projectMapper->insert($p);
368372
} else {
369-
if($p->locked && $this->userId != 'admin'){
373+
if($p->locked && !$this->isAdminUser()){
370374
return new JSONResponse(["Error" => "This project is locked"]);
371375
}
372376
}
@@ -474,7 +478,7 @@ public function getProjects(){
474478
* @NoCSRFRequired
475479
*/
476480
public function getProjectsTable(){
477-
if ($this->userId == 'admin'){
481+
if ($this->isAdminUser()){
478482
$projects = $this->projectMapper->findAllAdmin();
479483
} else {
480484
$projects = $this->projectMapper->findAll($this->userId);
@@ -519,8 +523,7 @@ public function addTag($name) {
519523
$c->setUserUid($this->userId);
520524
$c->setCreatedAt(time());
521525
$this->tagMapper->insert($c);
522-
}
523-
if ($c != null){
526+
} else if ($c != null){
524527
return new JSONResponse(["Error" => "This tag name already exists"]);
525528
}
526529

@@ -612,7 +615,8 @@ public function getReport(){
612615
$name = $this->userId;
613616
}
614617

615-
if($this->userId != 'admin'){
618+
619+
if($this->isAdminUser()){
616620
$allowedClients = $this->clientMapper->findAll($this->userId);
617621
$allowedClientsId = array_map(function($client){ return $client->id;}, $allowedClients );
618622
if(empty($filterClientId)){

0 commit comments

Comments
 (0)