Skip to content
This repository has been archived by the owner on Nov 18, 2018. It is now read-only.

Commit

Permalink
Only show public keys when not authenticated.
Browse files Browse the repository at this point in the history
  • Loading branch information
Niek Haarman committed Nov 3, 2014
1 parent ada54bf commit 00097dc
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Label305/Auja/Main/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ class Main extends AujaItem {

const COLOR_ALERT = "alert";

/**
* @var String[] The keys that are allowed to be visible to the public.
*/
private $public = ['title', 'authenticated', 'debug', 'colors', 'authentication'];

/**
* @var String The title.
*/
Expand Down Expand Up @@ -217,12 +222,11 @@ public function jsonSerialize() {
$result['user'] = array('name' => $this->getUsername());

$result['buttons'] = array();
foreach($this->getButtons() as $button){
foreach ($this->getButtons() as $button) {
$result['buttons'][] = $button->jsonSerialize();
}

$result['menu'] = array();

foreach ($this->getItems() as $item) {
$result['menu'][] = $item->jsonSerialize();
}
Expand All @@ -231,6 +235,10 @@ public function jsonSerialize() {
$result['authentication'] = $this->getAuthenticationForm()->aujaSerialize();
}

return $result;
if (!$this->isAuthenticated()) {
return array_intersect_key($result, array_flip($this->public));
} else {
return $result;
}
}
}

0 comments on commit 00097dc

Please sign in to comment.