fix home-page (need to fix unauthorized access to shared tactic)
continuous-integration/drone/push Build is failing Details

shareTactic
Vivien DUFOUR 1 year ago
parent 51f150a16a
commit 86a25d18b2

@ -29,7 +29,6 @@ export default function Home({
teams: Team[] teams: Team[]
username: string username: string
}) { }) {
console.log(allTactics)
return ( return (
<div id="main"> <div id="main">
<Header username={username} /> <Header username={username} />

@ -65,4 +65,16 @@ class TacticController
$this->teams->unshareTactic($tacticId); $this->teams->unshareTactic($tacticId);
return ViewHttpResponse::redirect("/"); return ViewHttpResponse::redirect("/");
} }
public function unshareTacticToTeam(int $tacticId, int $teamId, SessionHandle $session) : HttpResponse
{
$this->teams->unshareTacticToTeam($tacticId, $teamId);
return ViewHttpResponse::redirect("/");
}
public function unshareTacticToAccount(int $tacticId, int $accountId, SessionHandle $session) : HttpResponse
{
$this->tactics->unshareTacticToAccount($tacticId, $accountId);
return ViewHttpResponse::redirect("/");
}
} }

@ -36,20 +36,17 @@ class UserController {
$allTactics = $this->tactics->getAll($user->getId()); $allTactics = $this->tactics->getAll($user->getId());
$name = $user->getName(); $name = $user->getName();
if ($this->teams != null) { $allTacticsShared = $this->tactics->getAllTacticShared($user->getId());
$teams = $this->teams->getAll($user->getId()); if(isset($allTacticsShared)) {
foreach ($allTacticsShared as $tactic) {
$allTacticsShared = $this->tactics->getAllTacticShared($user->getId()); if(!in_array($tactic, $allTactics)) {
if(isset($allTacticsShared)) { array_push($allTactics, $tactic);
foreach ($allTacticsShared as $tactic) {
if(!in_array($tactic, $allTactics)) {
array_push($allTactics, $tactic);
}
} }
} }
}
var_dump($allTactics); if ($this->teams != null) {
var_dump($teams); $teams = $this->teams->getAll($user->getId());
} else { } else {
$teams = []; $teams = [];
} }

@ -2,7 +2,7 @@
namespace IQBall\Core\Data; namespace IQBall\Core\Data;
class TacticInfo { class TacticInfo implements \JsonSerializable {
private int $id; private int $id;
private string $name; private string $name;
private int $creationDate; private int $creationDate;
@ -59,4 +59,9 @@ class TacticInfo {
public function getCreationDate(): int { public function getCreationDate(): int {
return $this->creationDate; return $this->creationDate;
} }
public function jsonSerialize()
{
return get_object_vars($this);
}
} }

@ -113,4 +113,16 @@ class AccountGateway {
return intval($this->con->lastInsertId()); return intval($this->con->lastInsertId());
} }
public function unshareTacticToAccount(int $tacticId, int $accountId): int {
$this->con->exec(
"DELETE FROM TacticSharedAccount WHERE id_tactic = :tacticId AND id_account = :accountId",
[
":tacticId" => [$tacticId, PDO::PARAM_INT],
":accountId" => [$accountId, PDO::PARAM_INT],
]
);
return intval($this->con->lastInsertId());
}
} }

@ -54,6 +54,16 @@ class TeamGateway {
return intval($this->con->lastInsertId()); return intval($this->con->lastInsertId());
} }
public function unshareTacticToTeam(int $tacticId, int $teamId): int {
$this->con->exec(
"DELETE FROM TacticSharedTeam WHERE id_tactic = :tacticId AND id_team = :teamId",
[
":tacticId" => [$tacticId, PDO::PARAM_INT],
":teamId" => [$teamId, PDO::PARAM_INT],
]
);
return intval($this->con->lastInsertId());
}
/** /**

@ -188,4 +188,9 @@ class TacticModel {
{ {
return $this->users->unshareTactic($tacticId); return $this->users->unshareTactic($tacticId);
} }
public function unshareTacticToAccount(int $tacticId, int $accountId): int
{
return $this->users->unshareTacticToAccount($tacticId, $accountId);
}
} }

@ -88,6 +88,9 @@ class TeamModel {
return $this->teams->unshareTactic($tacticId); return $this->teams->unshareTactic($tacticId);
} }
public function unshareTacticToTeam(int $tacticId, int $teamId): int {
return $this->teams->unshareTacticToTeam($tacticId, $teamId);
}
/** /**
* delete a member from given team identifier * delete a member from given team identifier

Loading…
Cancel
Save