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[]
username: string
}) {
console.log(allTactics)
return (
<div id="main">
<Header username={username} />

@ -65,4 +65,16 @@ class TacticController
$this->teams->unshareTactic($tacticId);
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,9 +36,6 @@ class UserController {
$allTactics = $this->tactics->getAll($user->getId());
$name = $user->getName();
if ($this->teams != null) {
$teams = $this->teams->getAll($user->getId());
$allTacticsShared = $this->tactics->getAllTacticShared($user->getId());
if(isset($allTacticsShared)) {
foreach ($allTacticsShared as $tactic) {
@ -48,8 +45,8 @@ class UserController {
}
}
var_dump($allTactics);
var_dump($teams);
if ($this->teams != null) {
$teams = $this->teams->getAll($user->getId());
} else {
$teams = [];
}

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

@ -113,4 +113,16 @@ class AccountGateway {
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());
}
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);
}
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);
}
public function unshareTacticToTeam(int $tacticId, int $teamId): int {
return $this->teams->unshareTacticToTeam($tacticId, $teamId);
}
/**
* delete a member from given team identifier

Loading…
Cancel
Save