소스 검색

Correction indication utilisateur ajouté quand il ne l'est pas

Loquicom 5 년 전
부모
커밋
a88c5ccce7
2개의 변경된 파일10개의 추가작업 그리고 5개의 파일을 삭제
  1. 9 5
      node/src/db.js
  2. 1 0
      readme.md

+ 9 - 5
node/src/db.js

@@ -75,12 +75,16 @@ Db.prototype.addUser = function (username, passwordhash) {
     if (typeof username !== 'string' && typeof passwordhash !== 'string') {
         return false;
     }
-    this.userExist(username).then((result) => {
-        if (!result) {
-            this._execute(sql.insertUser, [username, passwordhash]);
-        }
+    return new Promise((resolve, resject) => {
+        this.userExist(username).then((result) => {
+            if (!result) {
+                this._execute(sql.insertUser, [username, passwordhash]);
+                resolve(true);
+            } else {
+                resolve(false);
+            }
+        });
     });
-    return true;
 };
 
 Db.prototype.listFile = function (username) {

+ 1 - 0
readme.md

@@ -24,6 +24,7 @@ Les codes d'erreurs sont les suivants :
 - 04 : Jeton invalide
 - 05 : Erreur serveur
 - 06 : Fichier introuvable
+- 07 : Utilisateur existant
 
 ## Points d'éntrées