From 32899286f7ba54c647f7fedaa25e49032b591dc6 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Tue, 8 Nov 2016 10:25:15 +0100 Subject: [PATCH] [module/authentification/renew] created --- build/api/module/authentification.php | 32 +++++++++++++++++++ build/error/core/Error.php | 45 +++++++++++++++------------ public_html/test.php | 12 ------- 3 files changed, 57 insertions(+), 32 deletions(-) create mode 100644 build/api/module/authentification.php delete mode 100644 public_html/test.php diff --git a/build/api/module/authentification.php b/build/api/module/authentification.php new file mode 100644 index 0000000..cc40739 --- /dev/null +++ b/build/api/module/authentification.php @@ -0,0 +1,32 @@ + New hash + * + */ + public static function renew($args){ + extract($args); + + /* (1) Fetch cyclic-hashing-system -> check file */ + $fn = __BUILD__.'/api/chs/hash'; + + if( !is_file($fn) ) + return ['ModuleError'=>Error::UnreachableResource]; + + /* (2) Stores new hash */ + file_put_contents($fn, $hash); + + + return []; + } + + } diff --git a/build/error/core/Error.php b/build/error/core/Error.php index 75080c3..060f103 100755 --- a/build/error/core/Error.php +++ b/build/error/core/Error.php @@ -72,6 +72,10 @@ // Mauvais format de fichier const FormatError = 18; + /* Cyclic Hash Error */ + // Expired + const CyclicHashExpired = 19; + /* Erreur au niveau javascript */ //const JavascriptError = 19; // -> géré en js @@ -85,32 +89,33 @@ */ public static function explicit($error){ switch($error){ - case self::Success: return "Tout s'est bien deroulé."; break; + case self::Success: return "All right man!"; break; - case self::ParsingFailed: return "La lecture du fichier JSON ou XML a echouée."; break; + case self::ParsingFailed: return "Parsing failed (json, xml, etc). Check your format."; break; - case self::InvalidFlags: return "Les spécifications (drapeaux) sont incorrects."; break; - case self::UnreachableResource: return "La ressource n'existe pas (404)."; break; - case self::MissingPath: return "Le chemin de délégation n'a pas été renseigné."; break; - case self::WrongPathModule: return "Le chemin de délégation est incorrect ('nomModule/nomMethode')."; break; - case self::WrongPathRepo: return "Le chemin de délégation est incorrect ('nomRepo/nomMethode')."; break; - case self::UnknownModule: return "Le module n'existe pas."; break; - case self::UnknownRepo: return "Le repo n'existe pas."; break; - case self::UnknownMethod: return "Le methode n'existe pas."; break; - case self::UncallableMethod: return "Le methode n'est pas amorçable."; break; + case self::InvalidFlags: return "You sent invalid flags."; break; + case self::UnreachableResource: return "Resource unreachable."; break; + case self::MissingPath: return "The @path is missing"; break; + case self::WrongPathModule: return "Invalid @path ('moduleName/methodName')."; break; + case self::WrongPathRepo: return "Invalid @path ('repoName/methodName')."; break; + case self::UnknownModule: return "Module not found."; break; + case self::UnknownRepo: return "Repository not found."; break; + case self::UnknownMethod: return "The method doesn't exist."; break; + case self::UncallableMethod: return "The method can't be called."; break; - case self::ParamError: return "Un ou plusieurs paramètres sont manquants ou incorrects."; break; - case self::ModuleError: return "Erreur lors du traitement du module."; break; - case self::RepoError: return "Erreur lors du traitement du repo."; break; + case self::ParamError: return "Missing or wrong arguments."; break; + case self::ModuleError: return "Module error."; break; + case self::RepoError: return "Repository error."; break; - case self::PDOConnection: return "La connexion avec la base de données a echouée."; break; + case self::PDOConnection: return "Database connection failed."; break; - case self::TokenError: return "Le token de connection est absent, érroné ou expiré."; break; - case self::PermissionError: return "Vous n'avez pas la permission d'effectuer cette action."; break; - case self::UploadError: return "Une erreur d'upload est survenue."; break; - case self::FormatError: return "Le fichier n'est pas au bon format."; break; + case self::TokenError: return "Missing or wrong token."; break; + case self::PermissionError: return "Permission denied."; break; + case self::UploadError: return "Upload error"; break; + case self::FormatError: return "Format error."; break; + case self::CyclicHashExpired: return "Cyclic hash has to be renewed."; break; - default: return "Description d'erreur inconnue..."; break; + default: return "Unknown Error..."; break; } // Erreur inconnue diff --git a/public_html/test.php b/public_html/test.php deleted file mode 100644 index c706230..0000000 --- a/public_html/test.php +++ /dev/null @@ -1,12 +0,0 @@ -