diff --git a/server/core.php b/server/core.php
index 306c88f..219d087 100644
--- a/server/core.php
+++ b/server/core.php
@@ -371,7 +371,7 @@ class user{
}
public function requireRole($role, $adminGranted=true){
- return $this->auth->hasRole($role) || $this->auth->hasRole(Role::SUPER_ADMIN) || ($this->auth->hasRole(Role::ADMIN) && $adminGranted && $role !== Role::DEVELOPER);
+ return $this->auth->hasRole($role) || $adminGranted && $role !== Role::DEVELOPER && $this->auth->hasRole(Role::ADMIN) || $role !== Role::DEVELOPER && $this->auth->hasRole(Role::SUPER_ADMIN);
}
public function name($replace=false){
@@ -423,7 +423,7 @@ class user{
}
public function info(){
- return array("id" => $this->auth->getUserId(), "name" => $this->name(), "full_viewer" => $this->requireRole(Role::FULL_VIEWER), "tester" => $this->requireRole(Role::TESTER), "developer" => $this->requireRole(Role::DEVELOPER));
+ return array("autenticated" => $this->authenticated(), "id" => $this->auth->getUserId(), "name" => $this->name(), "full_viewer" => $this->requireRole(Role::FULL_VIEWER), "tester" => $this->requireRole(Role::TESTER), "developer" => $this->requireRole(Role::DEVELOPER));
}
public function login($name, $password, $twofa=null){
@@ -585,11 +585,11 @@ function init_class($enableDebugger=true){
$translations = new translations();
}
if($enableDebugger){
- //if($user->requireRole(Role::DEVELOPER)){
- Debugger::enable(Debugger::DEVELOPMENT, __DIR__ . '/error-log');
- //} else {
- //Debugger::enable(Debugger::PRODUCTION, __DIR__ . '/error-log');
- //}
+ if($user->requireRole(Role::DEVELOPER)){
+ Debugger::enable(Debugger::DEVELOPMENT, __DIR__ . '/error-log');
+ } else {
+ Debugger::enable(Debugger::PRODUCTION, __DIR__ . '/error-log');
+ }
}
bdump(get_included_files());
bdump($translations->loaded_translations);
diff --git a/server/install/install.php b/server/install/install.php
index a7f9095..3bde421 100644
--- a/server/install/install.php
+++ b/server/install/install.php
@@ -222,7 +222,17 @@ if(!is_cli()){
Attivando questa opzione, l'user che verrà creato sarà visibile negli elenchi e nelle procedure.
-
+
+
+
+
+ Aggiungi i permessi di sviluppatore |
+
+
|
@@ -242,7 +252,7 @@ if(!is_cli()){
diff --git a/server/install/installHelper.php b/server/install/installHelper.php
index 37688f8..0cbeb80 100644
--- a/server/install/installHelper.php
+++ b/server/install/installHelper.php
@@ -369,14 +369,6 @@ INSERT INTO `".$prefix."_tipo` (`id`, `name`) VALUES (NULL, 'type1'), (NULL, 'ty
}
}
-final class Role {
- //https://github.com/delight-im/PHP-Auth/blob/master/src/Role.php
- const SUPER_ADMIN = \Delight\Auth\Role::SUPER_ADMIN;
-
- public function __construct() {}
-
-}
-
function full_path()
{
$s = &$_SERVER;
@@ -393,14 +385,17 @@ function full_path()
return $url;
}
-function initOptions($name, $visible, $password, $report_email, $owner){
+function initOptions($name, $visible, $developer, $password, $report_email, $owner){
try{
require_once "../config.php";
$connection = new PDO("mysql:host=".DB_HOST.";dbname=".DB_NAME, DB_USER, DB_PASSWORD,[PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
$prefix = DB_PREFIX;
$auth = new \Delight\Auth\Auth($connection, $_SERVER['REMOTE_ADDR'], $prefix."_");
$userId = $auth->register($report_email, $password, $name);
- $auth->admin()->addRoleForUserById($userId, Role::SUPER_ADMIN);
+ $auth->admin()->addRoleForUserById($userId, \Delight\Auth\Role::SUPER_ADMIN);
+ if($developer){
+ $auth->admin()->addRoleForUserById($userId, \Delight\Auth\Role::DEVELOPER);
+ }
$option_check_cf_ip = empty($_SERVER['HTTP_CF_CONNECTING_IP']) ? "INSERT INTO `".$prefix."_options` (`id`, `name`, `value`, `enabled`, `created_time`, `last_edit`, `user_id`) VALUES ('11', 'check_cf_ip', 1, '1', current_timestamp(), current_timestamp(), '1');" : "INSERT INTO `".$prefix."_options` (`id`, `name`, `value`, `enabled`, `created_time`, `last_edit`, `user_id`) VALUES ('10', 'check_cf_ip', 0, '1', current_timestamp(), current_timestamp(), '1');";
$prep = $connection->prepare("
INSERT INTO `".$prefix."_profiles` (`id`, `hidden`) VALUES (NULL, :hidden);
diff --git a/server/templates/base.html b/server/templates/base.html
index 6da9066..603149d 100644
--- a/server/templates/base.html
+++ b/server/templates/base.html
@@ -300,6 +300,7 @@
}
});
+ {% if user.autenticated %}
+ {% endif %}
{% block menu %}