|
|
|
@ -5,10 +5,12 @@ namespace IQBall\App\Controller;
|
|
|
|
|
use IQBall\App\Session\SessionHandle;
|
|
|
|
|
use IQBall\App\ViewHttpResponse;
|
|
|
|
|
use IQBall\Core\Data\Account;
|
|
|
|
|
use IQBall\Core\Http\HttpCodes;
|
|
|
|
|
use IQBall\Core\Http\HttpRequest;
|
|
|
|
|
use IQBall\Core\Http\HttpResponse;
|
|
|
|
|
use IQBall\Core\Model\TeamModel;
|
|
|
|
|
use IQBall\Core\Validation\FieldValidationFail;
|
|
|
|
|
use IQBall\Core\Validation\ValidationFail;
|
|
|
|
|
use IQBall\Core\Validation\Validators;
|
|
|
|
|
|
|
|
|
|
class TeamController {
|
|
|
|
@ -129,8 +131,15 @@ class TeamController {
|
|
|
|
|
* @return ViewHttpResponse a view that displays given team information
|
|
|
|
|
*/
|
|
|
|
|
public function displayTeam(int $id, SessionHandle $session): ViewHttpResponse {
|
|
|
|
|
$result = $this->model->getTeam($id);
|
|
|
|
|
return ViewHttpResponse::twig('display_team.html.twig', ['team' => $result]);
|
|
|
|
|
$result = $this->model->getTeam($id,$session->getAccount()->getId());
|
|
|
|
|
if($result == null){
|
|
|
|
|
return ViewHttpResponse::twig('error.html.twig', [
|
|
|
|
|
'failures' => [ValidationFail::unauthorized("Vous n'avez pas accès à cette équipe.")],
|
|
|
|
|
], HttpCodes::FORBIDDEN);
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
return ViewHttpResponse::twig('display_team.html.twig', ['team' => $result]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -167,4 +176,6 @@ class TeamController {
|
|
|
|
|
]);
|
|
|
|
|
return $this->displayTeam($this->model->deleteMember($request['email'], intval($request['team'])), $session);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|