From b1ca22d9b5ad41fa28d2d9b0a7a5638c06ce71f0 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Fri, 17 Feb 2017 15:13:48 +0100 Subject: [PATCH] [Fixed] Rearranged username/names fields' types (allow utf-8 + spaces) --- build/api/core/Checker.php | 8 ++------ config/modules.json | 24 ++++++++++++------------ public_html/index.php | 4 ++-- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/build/api/core/Checker.php b/build/api/core/Checker.php index 65e9262..6ee96d9 100644 --- a/build/api/core/Checker.php +++ b/build/api/core/Checker.php @@ -96,15 +96,11 @@ break; case 'alphanumeric': - return $checker && is_string($value) && preg_match('/^[\w\.-]+$/ui', $value); - break; - - case 'lettersutf8': - return $checker && is_string($value) && preg_match('/^[^\W\d]+$/ui', $value); + return $checker && is_string($value) && preg_match('/^[\w\.-]*$/ui', $value); break; case 'letters': - return $checker && is_string($value) && preg_match('/^[a-z -]+$/i', $value); + return $checker && is_string($value) && preg_match('/^\w[\w\. -]*$/ui', $value); break; case 'status': diff --git a/config/modules.json b/config/modules.json index e72845b..cde01cd 100755 --- a/config/modules.json +++ b/config/modules.json @@ -63,7 +63,7 @@ "permissions": [], "parameters": { "name": { "description": "Nom de l'entrepot.", "type": "varchar(3,30,alphanumeric)" }, - "password": { "description": "Mot de passe de l'entrepot.", "type": "text" } + "password": { "description": "Mot de passe de l'entrepot.", "type": "text" } }, "output": { "status": { "description": "Status de la connexion.", "type": "boolean" } @@ -74,7 +74,7 @@ "description": "Connexion de second niveau : administrateur.", "permissions": ["warehouse"], "parameters": { - "username": { "description": "Identifiant de l'administrateur.", "type": "varchar(1,30,alphanumeric)" }, + "username": { "description": "Identifiant de l'administrateur.", "type": "varchar(1,30,alphanumeric)" }, "password": { "description": "Mot de passe de l'administrateur'.", "type": "text" } }, "output": { @@ -92,8 +92,8 @@ "parameters": { "code": { "description": "Code RFID de l'utilisateur.", "type": "rfid" }, "username": { "description": "Identifiant de l'utilisateur.", "type": "varchar(1,30,alphanumeric)" }, - "firstname": { "description": "Prénom de l'utilisateur.", "type": "varchar(3,30,lettersutf8)" }, - "lastname": { "description": "Nom de l'utilisateur.", "type": "varchar(3,30,lettersutf8)" }, + "firstname": { "description": "Prénom de l'utilisateur.", "type": "varchar(3,30,letters)" }, + "lastname": { "description": "Nom de l'utilisateur.", "type": "varchar(3,30,letters)" }, "mail": { "description": "Adresse mail de l'utilisateur.", "type": "mail" } }, "output": { @@ -193,8 +193,8 @@ "id_user": { "description": "UID de l'utilisateur.", "type": "id" }, "code": { "description": "Code RFID de l'utilisateur.", "type": "rfid", "optional": true }, "username": { "description": "Identifiant de l'utilisateur.", "type": "varchar(1,30,alphanumeric)", "optional": true }, - "firstname": { "description": "Prénom de l'utilisateur.", "type": "varchar(3,30,lettersutf8)", "optional": true }, - "lastname": { "description": "Nom de l'utilisateur.", "type": "varchar(3,30,lettersutf8)", "optional": true }, + "firstname": { "description": "Prénom de l'utilisateur.", "type": "varchar(3,30,letters)", "optional": true }, + "lastname": { "description": "Nom de l'utilisateur.", "type": "varchar(3,30,letters)", "optional": true }, "mail": { "description": "Adresse mail de l'utilisateur.", "type": "mail", "optional": true }, "password": { "description": "Mot de passe de l'utilisateur.", "type": "text", "optional": true }, "status": { "description": "Status de l'utilisateur.", "type": "status", "optional": true } @@ -249,7 +249,7 @@ "description": "Création d'une nouvelle machine.", "permissions": ["warehouse", "admin"], "parameters": { - "name": { "description": "Nom de la machine.", "type": "varchar(1,30,alphanumeric)" } + "name": { "description": "Nom de la machine.", "type": "varchar(1,30,letters)" } }, "output": { "id_machine": { "description": "UID de la machine.", "type": "id" } @@ -311,7 +311,7 @@ "description": "Retourne les données d'une machine de nom donné.", "permissions": ["warehouse", "admin"], "parameters": { - "name": { "description": "Nom de la machine.", "type": "varchar(1,30,alphanumeric)" } + "name": { "description": "Nom de la machine.", "type": "varchar(1,30,letters)" } }, "output": { "machine": { "description": "Données de la machine.", "type": "array" } @@ -334,7 +334,7 @@ "permissions": ["warehouse", "admin"], "parameters": { "id_machine": { "description": "UID de la machine.", "type": "id" }, - "name": { "description": "Nom de la machine.", "type": "varchar(1,30,alphanumeric)", "optional": true } + "name": { "description": "Nom de la machine.", "type": "varchar(1,30,letters)", "optional": true } }, "output": {} }, @@ -359,7 +359,7 @@ "description": "Création d'un nouveau groupe.", "permissions": ["warehouse", "admin"], "parameters": { - "name": { "description": "Nom du groupe.", "type": "varchar(1,30,alphanumeric)" }, + "name": { "description": "Nom du groupe.", "type": "varchar(1,30,letters)" }, "class": { "description": "Type de groupe.", "type": "id" } }, "output": { @@ -406,7 +406,7 @@ "description": "Retourne un groupe de nom donné.", "permissions": ["warehouse", "admin"], "parameters": { - "name": { "description": "Nom du groupe.", "type": "varchar(1,30,alphanumeric)" }, + "name": { "description": "Nom du groupe.", "type": "varchar(1,30,letters)" }, "class": { "description": "Type de groupe.", "type": "id" } }, "output": { @@ -432,7 +432,7 @@ "parameters": { "id_cluster": { "description": "UID du groupe.", "type": "id" }, "class": { "description": "Type de groupe.", "type": "id" }, - "name": { "description": "Nom du groupe.", "type": "varchar(1,30,alphanumeric)" } + "name": { "description": "Nom du groupe.", "type": "varchar(1,30,letters)" } }, "output": { "status": { "description": "Status de la modification.", "type": "boolean" } diff --git a/public_html/index.php b/public_html/index.php index eca814e..db00ca4 100755 --- a/public_html/index.php +++ b/public_html/index.php @@ -86,7 +86,7 @@ // logout from admin $R->get('logout/?', function(){ $_SERVER['REQUEST_METHOD'] = 'POST'; - $req = new Request('authentificationDefault/admin', ['username' => '0', 'password' => '']); + $req = new Request('authentificationDefault/admin', ['username' => ' ', 'password' => '']); $res = $req->dispatch(); header('Location: /'); }); @@ -110,7 +110,7 @@ // warehouse logout $R->get('logout/?', function(){ $_SERVER['REQUEST_METHOD'] = 'POST'; - (new Request('authentificationDefault/warehouse', ['name' => '000', 'password' => '']))->dispatch(); + (new Request('authentificationDefault/warehouse', ['name' => ' ', 'password' => '']))->dispatch(); header('Location: /'); });