Commit 3f5a8a8c authored by raphael.peim's avatar raphael.peim

Finish backend tp4

parent 3f469b49
......@@ -22,6 +22,11 @@
return new Response(400, $message);
}
public static function unauthorizedResponse($message = "")
{
return new Response(401, $message);
}
public static function notFoundResponse($message = "")
{
return new Response(404, $message);
......
......@@ -73,34 +73,23 @@
protected function updateUser($put, $id) {
$user = User::getWithId($id);
// var_dump(Request::getCurrentRequest());
// if (!empty($put) && !empty($user)) {
// try {
// $jwt_token = $this->request->getJwtToken();
// $decodedJWT = JWT::decode($jwt_token, JWT_BACKEND_KEY, array('HS256'));
// var_dump($decodedJWT->data);
// }
// catch (Exception $e){
// header('WWW-Authenticate: Bearer realm="' . JWT_ISSUER . '"');
// $jsonResult = json_encode(array(
// "message" => "Access denied.",
// "error" => $e->getMessage()
// ));
// return Response::unauthorizedResponse($jsonResult);
// }
// }
// else {
// return Response::notFoundResponse("Aucun utilisateur modifié");
// }
// User::update($put, $id);
// $response = Response::okResponse("Utilisateur modifié");
// return $response;
if (!empty($put) && !empty($user)) {
$jwt_token = $this->request->getJwtToken();
$jwt = JWT::decode($jwt_token, JWT_BACKEND_KEY, array('HS256'));
if ($jwt->data->id == $id) {
User::update($put, $id);
$response = Response::okResponse("Utilisateur modifié");
return $response;
}
else {
return Response::unauthorizedResponse("Modification non autorisée");
}
}
else {
return Response::notFoundResponse("Aucun utilisateur modifié");
}
}
protected function deleteUser($id) {
......
......@@ -32,10 +32,6 @@
<i class="fas fa-angle-up"></i>
</a>
<script src="vendor/jquery/jquery.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.js"></script>
<script src="vendor/jquery-easing/jquery.easing.js"></script>
<script src="js/sb-admin-2.js"></script>
<script src="vendor/chart.js/Chart.js"></script>
<?php require_once('js.php'); ?>
</body>
</html>
\ No newline at end of file
......@@ -46,10 +46,6 @@
<i class="fas fa-angle-up"></i>
</a>
<script src="vendor/jquery/jquery.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.js"></script>
<script src="vendor/jquery-easing/jquery.easing.js"></script>
<script src="js/sb-admin-2.js"></script>
<script src="vendor/chart.js/Chart.js"></script>
<?php require_once('js.php'); ?>
</body>
</html>
\ No newline at end of file
......@@ -53,10 +53,6 @@
<i class="fas fa-angle-up"></i>
</a>
<script src="vendor/jquery/jquery.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.js"></script>
<script src="vendor/jquery-easing/jquery.easing.js"></script>
<script src="js/sb-admin-2.js"></script>
<script src="vendor/chart.js/Chart.js"></script>
<?php require_once('js.php'); ?>
</body>
</html>
\ No newline at end of file
<?php
$page = explode('.php', end(explode('/', $_SERVER['REQUEST_URI'])))[0];
$page = $page == "" ? "index" : $page;
?>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
......
......@@ -25,6 +25,7 @@
<span class="icon text-white-50">
<i class="fas fa-book-open"></i>
</span>
<!-- <span class="text">Découvrez le mahjong</span> -->
<span class="text">Découvrez le mahjong</span>
</a>
<a href="login.php" class="btn btn-primary btn-icon-split btn-lg" style="display: flex;">
......@@ -43,10 +44,6 @@
<i class="fas fa-angle-up"></i>
</a>
<script src="vendor/jquery/jquery.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.js"></script>
<script src="vendor/jquery-easing/jquery.easing.js"></script>
<script src="js/sb-admin-2.js"></script>
<script src="vendor/chart.js/Chart.js"></script>
<?php require_once('js.php'); ?>
</body>
</html>
\ No newline at end of file
<?php
phpinfo();
?>
\ No newline at end of file
<script src="vendor/jquery/jquery.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.js"></script>
<script src="vendor/jquery-easing/jquery.easing.js"></script>
<script src="js/sb-admin-2.js"></script>
<script src="vendor/chart.js/Chart.js"></script>
<script <?php echo "src=\"js/$page.js\"" ?>></script>
\ No newline at end of file
console.log("Hey !");
\ No newline at end of file
......@@ -30,7 +30,7 @@
<hr>
</form>
<div class="text-center">
<a class="small" href="register.php">Créer un compte</a>
<a class="small" href="signup.php">Créer un compte</a>
</div>
</div>
</div>
......@@ -41,9 +41,6 @@
</div>
</div>
<script src="vendor/jquery/jquery.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.js"></script>
<script src="vendor/jquery-easing/jquery.easing.js"></script>
<script src="js/sb-admin-2.js"></script>
<?php require_once('js.php'); ?>
</body>
</html>
\ No newline at end of file
......@@ -32,10 +32,6 @@
<i class="fas fa-angle-up"></i>
</a>
<script src="vendor/jquery/jquery.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.js"></script>
<script src="vendor/jquery-easing/jquery.easing.js"></script>
<script src="js/sb-admin-2.js"></script>
<script src="vendor/chart.js/Chart.js"></script>
<?php require_once('js.php'); ?>
</body>
</html>
\ No newline at end of file
......@@ -53,9 +53,6 @@
</div>
</div>
<script src="vendor/jquery/jquery.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.js"></script>
<script src="vendor/jquery-easing/jquery.easing.js"></script>
<script src="js/sb-admin-2.js"></script>
<?php require_once('js.php'); ?>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment