add documentation
continuous-integration/drone/push Build is passing Details

pull/19/head
maxime.batista 1 year ago
parent 69be939954
commit e3875b4f15

@ -2,12 +2,10 @@
object Account {
<u>id
name
age
email
phoneNumber
passwordHash
profilePicture
username
token
hash
}
object Team {
@ -26,7 +24,7 @@ object TacticFolder {
object Tactic {
<u>id_json
name
creationDate
creation_date
}
usecase have_team [
@ -63,6 +61,10 @@ usecase contains_other_folder [
to contain
]
usecase owns [
owns
]
Account "0,n" -- have_team
have_team -- "1,n" Team
@ -73,6 +75,9 @@ shared_tactic_account -- "0,n" Tactic
Tactic "0,n" -- shared_tactic_team
shared_tactic_team -- "0,n" Team
Tactic "1,1" -- owns
owns -- Account
Team "0,n" -- shared_folder_team
shared_folder_team -- "0,n"TacticFolder

@ -17,7 +17,6 @@ use App\Http\ViewHttpResponse;
use App\Model\AuthModel;
use App\Model\TacticModel;
use App\Session\PhpSessionHandle;
use App\Session\SessionHandle;
use App\Validation\ValidationFail;
function getTacticController(): APITacticController {
@ -28,6 +27,9 @@ function getAuthController(): APIAuthController {
return new APIAuthController(new AuthModel(new AccountGateway(new Connexion(get_database()))));
}
/**
* A Front controller action
*/
class Action {
/**
* @var callable(mixed[]): HttpResponse $action action to call

@ -1,13 +1,7 @@
-- drop tables here
DROP TABLE IF EXISTS FormEntries;
DROP TABLE IF EXISTS Account;
DROP TABLE IF EXISTS TacticInfo;
DROP TABLE IF EXISTS Tactic;
CREATE TABLE FormEntries
(
name varchar NOT NULL,
description varchar NOT NULL
);
CREATE TABLE Account
(
id integer PRIMARY KEY AUTOINCREMENT,
@ -17,7 +11,7 @@ CREATE TABLE Account
hash varchar NOT NULL
);
CREATE TABLE TacticInfo
CREATE TABLE Tactic
(
id integer PRIMARY KEY AUTOINCREMENT,
name varchar NOT NULL,

@ -18,7 +18,7 @@ class TacticInfoGateway {
public function get(int $id): ?TacticInfo {
$res = $this->con->fetch(
"SELECT * FROM TacticInfo WHERE id = :id",
"SELECT * FROM Tactic WHERE id = :id",
[":id" => [$id, PDO::PARAM_INT]]
);
@ -33,14 +33,14 @@ class TacticInfoGateway {
public function insert(string $name, int $owner): TacticInfo {
$this->con->exec(
"INSERT INTO TacticInfo(name, owner) VALUES(:name, :owner)",
"INSERT INTO Tactic(name, owner) VALUES(:name, :owner)",
[
":name" => [$name, PDO::PARAM_STR],
":owner" => [$owner, PDO::PARAM_INT],
]
);
$row = $this->con->fetch(
"SELECT id, creation_date, owner FROM TacticInfo WHERE :id = id",
"SELECT id, creation_date, owner FROM Tactic WHERE :id = id",
[':id' => [$this->con->lastInsertId(), PDO::PARAM_INT]]
)[0];
return new TacticInfo(intval($row["id"]), $name, strtotime($row["creation_date"]), $row["owner"]);
@ -48,7 +48,7 @@ class TacticInfoGateway {
public function updateName(int $id, string $name): void {
$this->con->exec(
"UPDATE TacticInfo SET name = :name WHERE id = :id",
"UPDATE Tactic SET name = :name WHERE id = :id",
[
":name" => [$name, PDO::PARAM_STR],
":id" => [$id, PDO::PARAM_INT],

@ -4,9 +4,17 @@ namespace App\Session;
use App\Data\Account;
/**
* The mutable side of a session handle
*/
interface MutableSessionHandle extends SessionHandle {
/**
* @param string|null $url the url to redirect the user to after authentication.
*/
public function setInitialTarget(?string $url): void;
/**
* @param Account $account update the session's account
*/
public function setAccount(Account $account): void;
}

@ -4,8 +4,11 @@ namespace App\Session;
use App\Data\Account;
/**
* A PHP session handle
*/
class PhpSessionHandle implements MutableSessionHandle {
public static function init(): SessionHandle {
public static function init(): self {
if (session_status() !== PHP_SESSION_NONE) {
throw new \Exception("A php session is already started !");
}

@ -4,8 +4,20 @@ namespace App\Session;
use App\Data\Account;
/**
* An immutable session handle
*/
interface SessionHandle {
/**
* The initial target url if the user wanted to perform an action that requires authentication
* but has been required to login first in the application.
* @return string|null Get the initial targeted URL
*/
public function getInitialTarget(): ?string;
/**
* The session account if the user is logged in.
* @return Account|null
*/
public function getAccount(): ?Account;
}

Loading…
Cancel
Save