commit 2fe1255a65c6f610fd468559fe4254817fc14ade
parent 7f34bca9a0d128df43558523fa4b1973ca1a7d5c
Author: Gerco van Woudenbergh <[email protected]>
Date: Mon, 3 Jul 2023 16:01:05 +0200
user mgmt
Diffstat:
3 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/Controller/Templates.php b/Controller/Templates.php
@@ -146,7 +146,7 @@ namespace Controller {
<td>';
if($permissionUser != null) {
foreach($this->db->all_where(\Model\PermissionUser::class, [$permissionUser->get_primary() => $obj->{$this->table->get_primary()}]) as $perm) {
- $table .= $perm->id . ' ';
+ $table .= $perm->id_permission . ' ';
}
}
$table .= '</td> </tr>';
diff --git a/index.php b/index.php
@@ -76,7 +76,7 @@ $router->addRoute(["GET"], "/api/:data", function ($key) {
}
});
-if(isset($_SESSION['user_permissions']) && in_array(1, $_SESSION['user_permissions'])) {
+if(isset($_SESSION['user_permissions']) && (in_array(1, $_SESSION['user_permissions']) || in_array(2, $_SESSION['user_permissions']))) {
//user
//add
$router->addRoute(["GET"], "/user/add", "views/add_user.html");
@@ -111,19 +111,20 @@ if(isset($_SESSION['user_permissions']) && in_array(1, $_SESSION['user_permissio
return "views/hdata.html";
});
-
- $router->addRoute(["GET"], "/user", $user_get);
+ //user management for admins
+ if(in_array(1, $_SESSION['user_permissions'])) {
+ $router->addRoute(["GET"], "/user", $user_get);
- $router->addRoute(["POST"], "/user", $user_post);
+ $router->addRoute(["POST"], "/user", $user_post);
- $router->addRoute(["GET"], "/user/search/:search_query", $user_query);
+ $router->addRoute(["GET"], "/user/search/:search_query", $user_query);
- $router->addRoute(["POST"], "/user/search", $user_search);
+ $router->addRoute(["POST"], "/user/search", $user_search);
- $router->addRoute(["GET"], "/user/:primary_key/edit", $user_edit);
-
- $router->addRoute(["GET"], "/user/:primary_key/delete", $user_delete);
+ $router->addRoute(["GET"], "/user/:primary_key/edit", $user_edit);
+ $router->addRoute(["GET"], "/user/:primary_key/delete", $user_delete);
+ }
}
// static files //
diff --git a/views/login.html b/views/login.html
@@ -18,7 +18,7 @@
<h1>Welcome to Panda Breeding Facilities</h1>
</div>
</div>
- </div>
+ </div> {{$session}}
<div class="container">
<div class="row justify-content-center">
<div class="col-md-6">