[Fixed] Rearranged username/names fields' types (allow utf-8 + spaces)

This commit is contained in:
xdrm-brackets 2017-02-17 15:13:48 +01:00
parent 1c7419cb67
commit 56882c1ecc
3 changed files with 16 additions and 20 deletions

View File

@ -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':

View File

@ -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<mixed>" }
@ -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" }

View File

@ -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: /');
});