| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704 |
- <?php
- /**
- * Classe `user`
- *
- * Cette classe gère les utilisateurs et leurs actions, telles que la récupération
- * des informations utilisateur, la gestion des jetons JWT, l'authentification,
- * la gestion des tags associés aux utilisateurs, et bien plus encore.
- */
- class user
- {
- /**
- * Récupère les informations d'un utilisateur.
- *
- * @param int $userId L'ID de l'utilisateur.
- * @return array|bool Les informations de l'utilisateur ou FALSE en cas d'erreur.
- */
- public static function getUser(int $_id)
- {
- // Récupération des données de l'excel au format Json
- db::query("SELECT "
- . "" . DB_T_USER . ".id AS id, "
- . "" . DB_T_USER . ".email ,"
- . "" . DB_T_USER . ".prenom, "
- . "" . DB_T_USER . ".nom, "
- . "" . DB_T_USER . ".cree, "
- . "" . DB_T_USER . ".last_connect, "
- . "" . DB_T_USER . ".googleAuthenticator, "
- . "" . DB_T_USER . ".actif, "
- . "" . DB_T_USER . ".deleted, "
- . "" . DB_T_USER . ".id_type, "
- . "" . DB_T_TYPE_USER . ".type "
- . "FROM " . DB_T_USER . " "
- . "INNER JOIN " . DB_T_TYPE_USER . " ON " . DB_T_USER . ".id_type = " . DB_T_TYPE_USER . ".id "
- . "WHERE " . DB_T_USER . ".id = :id");
- db::bind(':id', $_id);
- $return = db::single();
- $return["tags"] = self::getTags($_id);
- return $return;
- }
- /**
- * Récupère la liste des utilisateurs.
- *
- * @return array Liste des utilisateurs avec leurs informations et tags associés.
- */
- public static function getUsers()
- {
- // Récupération des données de l'excel au format Json
- db::query("SELECT "
- . "" . DB_T_USER . ".id, "
- . "" . DB_T_USER . ".email, "
- . "" . DB_T_USER . ".prenom, "
- . "" . DB_T_USER . ".nom, "
- . "" . DB_T_USER . ".cree, "
- . "" . DB_T_USER . ".last_connect, "
- . "" . DB_T_USER . ".googleAuthenticator, "
- . "" . DB_T_USER . ".actif, "
- . "" . DB_T_USER . ".id_type, "
- . "" . DB_T_TYPE_USER . ".type "
- . "FROM " . DB_T_USER . " "
- . "INNER JOIN " . DB_T_TYPE_USER . " ON " . DB_T_USER . ".id_type = " . DB_T_TYPE_USER . ".id "
- . "WHERE " . DB_T_USER . ".deleted = 0");
- $return = db::resultset();
- foreach ($return as $key => $users) {
- $return[$key] = $users;
- $return[$key]["tags"] = self::getTags($users["id"]);
- }
- return $return;
- }
- /**
- * Récupère le nom complet d'un utilisateur par son identifiant.
- *
- * @param int $_id Identifiant de l'utilisateur.
- * @return string Nom complet de l'utilisateur.
- */
- public static function getNameById(int $_id)
- {
- db::query("SELECT "
- . "CONCAT (" . DB_T_USER . ".prenom, ' ', " . DB_T_USER . ".nom) AS 'name' "
- . "FROM " . DB_T_USER . " "
- . "WHERE " . DB_T_USER . ".id = :id");
- db::bind(':id', $_id);
- return db::single()["name"];
- }
- /**
- * Récupère le secret Google Authenticator d'un utilisateur.
- *
- * @param int $_id Identifiant de l'utilisateur.
- * @return string Secret Google Authenticator.
- */
- public static function getMyGoogleAuthenticator(int $_id)
- {
- db::query("SELECT "
- . "" . DB_T_USER . ".googleAuthenticatorSecret "
- . "FROM " . DB_T_USER . " "
- . "WHERE " . DB_T_USER . ".id = :id");
- db::bind(':id', $_id);
- return db::single()["googleAuthenticatorSecret"];
- }
- /**
- * Vérifie si un utilisateur a activé Google Authenticator.
- *
- * @param string $_email Email de l'utilisateur.
- * @return int 1 si activé, 0 sinon.
- */
- public static function checkGoogleAuthenticator(string $_email)
- {
- db::query("SELECT "
- . "" . DB_T_USER . ".googleAuthenticator "
- . "FROM " . DB_T_USER . " "
- . "WHERE " . DB_T_USER . ".email = :email");
- db::bind(':email', $_email);
- $return = db::single();
- return (isset($return["googleAuthenticator"])) ? $return["googleAuthenticator"] : 0;
- }
- /**
- * Vérifie le statut du 2FA d'un utilisateur par son ID.
- *
- * @param int $_id Identifiant de l'utilisateur.
- * @return int 1 si activé, 0 sinon.
- */
- public static function check2FAStatus(int $_id): int
- {
- db::query("SELECT googleAuthenticator FROM " . DB_T_USER . " WHERE id = :id");
- db::bind(':id', $_id);
- $result = db::single();
- return isset($result["googleAuthenticator"]) ? (int)$result["googleAuthenticator"] : 0;
- }
- /**
- * Insère un jeton JWT pour un utilisateur.
- *
- * @param int $_id_user Identifiant de l'utilisateur.
- * @param string $_jwt Jeton JWT à insérer.
- * @return bool TRUE si l'insertion est réussie, FALSE sinon.
- */
- private static function insertJWT($_id_user, $_jwt)
- {
- self::deleteJWTbyUSer($_id_user);
- db::query("INSERT INTO " . DB_T_JWT . " (id_user, md5, jwt) VALUES (:id_user, :md5, :jwt)");
- db::bind(':id_user', $_id_user);
- db::bind(':md5', md5($_jwt));
- db::bind(':jwt', $_jwt);
- try {
- db::execute();
- return TRUE;
- } catch (Exception $ex) {
- return FALSE;
- }
- }
- /**
- * Supprime tous les jetons JWT d'un utilisateur.
- *
- * @param int $_id_user Identifiant de l'utilisateur.
- * @return bool TRUE si la suppression est réussie, FALSE sinon.
- */
- public static function deleteJWTbyUSer($_id_user)
- {
- db::query("DELETE FROM " . DB_T_JWT . " WHERE id_user = :id_user");
- db::bind(':id_user', $_id_user);
- try {
- db::execute();
- return TRUE;
- } catch (Exception $ex) {
- return FALSE;
- }
- }
- /**
- * Met à jour un jeton JWT par son empreinte MD5.
- *
- * @param string $_md5 Empreinte MD5 du jeton existant.
- * @param string $_jwt Nouveau jeton JWT.
- * @return bool TRUE si la mise à jour est réussie, FALSE sinon.
- */
- public static function updateJWTbyMd5($_md5, $_jwt)
- {
- db::query("UPDATE " . DB_T_JWT . " SET jwt = :jwt, md5 = :newmd5 WHERE md5 = :md5");
- db::bind(':md5', $_md5);
- db::bind(':jwt', $_jwt);
- db::bind(':newmd5', md5($_jwt));
- try {
- db::execute();
- return TRUE;
- } catch (Exception $ex) {
- return FALSE;
- }
- }
- /**
- * Récupère les informations d'un utilisateur à partir d'un jeton JWT.
- *
- * @param string $_jwt Jeton JWT.
- * @return array|bool Informations de l'utilisateur ou FALSE si non trouvé.
- */
- public static function getInfosByJWT($_jwt)
- {
- db::query("SELECT id_user, creer FROM " . DB_T_JWT . " WHERE md5 = :md5");
- db::bind(':md5', md5($_jwt));
- $row = db::single();
- if (isset($row["id_user"])) {
- return $row;
- } else {
- return FALSE;
- }
- }
- /**
- * Authentifie un utilisateur avec ses informations d'entrée.
- *
- * @param array $_input Données d'entrée pour l'authentification.
- * @return array Résultat de l'authentification avec les informations utilisateur.
- */
- public static function authenticator(array $_input)
- {
- db::query("SELECT id, email, password, prenom, nom, id_type, googleAuthenticator, googleAuthenticatorSecret, actif FROM " . DB_T_USER . " WHERE email = :email AND deleted = 0");
- db::bind(':email', $_input["email"]);
- $row = db::single();
- if (isset($row["id"])) {
- if ($row["actif"] == 0) {
- return [
- "status" => "error",
- "type" => "actif"
- ];
- } elseif (isset($_input["password"]) and md5($_input["password"]) == $row["password"]) {
- return [
- "status" => "success",
- "type" => "authent",
- "id" => $row["id"],
- "prenom" => $row["prenom"],
- "nom" => $row["nom"],
- "googleAuthenticator" => $row["googleAuthenticator"],
- "googleAuthenticatorSecret" => $row["googleAuthenticatorSecret"],
- "idType" => $row["id_type"],
- "email" => $row["email"],
- "actif" => $row["actif"],
- "iat" => time(),
- "exp" => time() + JWT_DURATION
- ];
- } else {
- return [
- "status" => "error",
- "type" => "authent"
- ];
- }
- } else {
- return [
- "status" => "error",
- "type" => "unknown"
- ];
- }
- }
- /**
- * Connecte un utilisateur en vérifiant ses informations d'entrée.
- *
- * @param array $_input Données d'entrée pour la connexion.
- * @return bool TRUE si la connexion est réussie, FALSE sinon.
- */
- public static function connect(array $_input)
- {
- $connect = jwt::authenticate($_input);
- if ($connect["googleAuthenticator"] == 1 and DOMAIN_CONTROL != $_SERVER['SERVER_NAME']) {
- if (googleAuthenticator::verifyCode($connect["googleAuthenticatorSecret"], $_input["authenticator"], 1) == FALSE) {
- $connect["id"] = NULL;
- }
- }
- if (isset($connect["id"])) {
- if ($connect["status"] == "success") {
- $_SESSION["user"] = array(
- "id" => $connect["id"],
- "prenom" => $connect["prenom"],
- "nom" => $connect["nom"],
- "googleAuthenticator" => $connect["googleAuthenticator"],
- "idType" => $connect["idType"],
- "email" => $connect["email"],
- "actif" => $connect["actif"],
- "token" => $connect["token"]
- );
- self::updateLastConnect($connect["id"]);
- self::insertJWT($connect["id"], $connect["token"]);
- return TRUE;
- } else {
- if ($connect["type"] == "actif") {
- alert::recError("Votre compte est désactivé");
- return FALSE;
- } elseif ($connect["type"] == "authent") {
- alert::recError("Erreur d'authentification");
- return FALSE;
- } elseif ($connect["type"] == "unknown") {
- alert::recError("Erreur d'authentification");
- return FALSE;
- }
- }
- } else {
- alert::recError("Erreur d'authentification");
- return FALSE;
- }
- }
- /**
- * Met à jour la date de dernière connexion d'un utilisateur.
- *
- * @param int $_id Identifiant de l'utilisateur.
- */
- private static function updateLastConnect(int $_id)
- {
- db::query("UPDATE " . DB_T_USER . " SET `last_connect` = CURRENT_TIMESTAMP() WHERE id = :id");
- db::bind(':id', $_id);
- db::execute();
- }
- /**
- * Ajoute un nouvel utilisateur dans la base de données.
- *
- * @param array $_input Données de l'utilisateur à ajouter.
- */
- public static function add_user(array $_input)
- {
- db::query("INSERT INTO " . DB_T_USER . " "
- . "(email, password, googleAuthenticator, googleAuthenticatorSecret, prenom, nom, id_type, actif) "
- . "VALUES (:email, :password, :googleAuthenticator, :googleAuthenticatorSecret, :prenom, :nom, :id_type, :actif)");
- db::bind(':email', $_input["email"]);
- db::bind(':password', md5($_input["password"]));
- db::bind(':prenom', $_input["prenom"]);
- db::bind(':nom', $_input["nom"]);
- db::bind(':googleAuthenticator', $_input["googleAuthenticator"]);
- db::bind(':googleAuthenticatorSecret', googleAuthenticator::createSecret());
- db::bind(':id_type', $_input["id_type"]);
- db::bind(':actif', $_input["actif"]);
- try {
- db::execute();
- $tags = tags::textToId($_input["tags"], 1);
- self::addTags(db::lastInsertId(), $tags);
- alert::recSuccess("La création a bien été prise en compte");
- } catch (Exception $ex) {
- alert::recError("Erreur lors de la création de l'utilisateur");
- header("Location: /add-user.html");
- exit();
- }
- }
- /**
- * Récupère l'identifiant du dernier utilisateur ajouté.
- *
- * @return int Identifiant du dernier utilisateur.
- */
- public static function lastUser()
- {
- db::query("SELECT MAX(id) AS id FROM " . DB_T_USER);
- return db::single()["id"];
- }
- /**
- * Met à jour les informations d'un utilisateur existant.
- *
- * @param array $_input Données mises à jour de l'utilisateur.
- */
- public static function maj_user(array $_input)
- {
- if ($_input["password"] != "") {
- db::query("UPDATE " . DB_T_USER . " SET password = :password WHERE id = :id");
- db::bind(':password', md5($_input["password"]));
- db::bind(':id', $_input["id"]);
- try {
- db::execute();
- } catch (Exception $ex) {
- alert::recError("Erreur lors de la modification du mot de passe");
- header("Location: /user-" . $_input["id"] . ".html");
- exit();
- }
- }
- if (self::getMyGoogleAuthenticator($_input["id"]) == NULL) {
- db::query("UPDATE " . DB_T_USER . " SET googleAuthenticatorSecret = :googleAuthenticatorSecret WHERE id = :id");
- db::bind(':googleAuthenticatorSecret', googleAuthenticator::createSecret());
- db::bind(':id', $_input["id"]);
- try {
- db::execute();
- } catch (Exception $ex) {
- alert::recError("Erreur lors de la création du token de Google Authenticator");
- header("Location: /user-" . $_input["id"] . ".html");
- exit();
- }
- }
- $tags = tags::textToId($_input["tags"], 1);
- self::addTags($_input["id"], $tags);
- // Vérifier si on active le 2FA (passage de 0 à 1)
- $current2FA = self::check2FAStatus($_input["id"]);
- $new2FA = isset($_input["googleAuthenticator"]) ? (int)$_input["googleAuthenticator"] : 0;
- // Si on veut activer le 2FA et qu'il n'est pas déjà actif, on le met en pending
- if ($new2FA == 1 && $current2FA == 0) {
- self::set2FAPending($_input["id"]);
- $googleAuthValue = 0; // Reste à 0 jusqu'à validation
- } else {
- $googleAuthValue = $new2FA;
- // Si on désactive le 2FA, on supprime aussi le pending
- if ($new2FA == 0) {
- self::cancel2FAPending($_input["id"]);
- }
- }
- db::query("UPDATE " . DB_T_USER . " SET
- email = :email,
- prenom = :prenom,
- nom = :nom,
- id_type = :id_type,
- googleAuthenticator = :googleAuthenticator,
- actif = :actif
- WHERE id = :id");
- db::bind(':email', $_input["email"]);
- db::bind(':prenom', $_input["prenom"]);
- db::bind(':nom', $_input["nom"]);
- db::bind(':googleAuthenticator', $googleAuthValue);
- db::bind(':id_type', $_input["id_type"]);
- db::bind(':actif', $_input["actif"]);
- db::bind(':id', $_input["id"]);
- try {
- db::execute();
- alert::recSuccess("La modification a bien été prise en compte");
- } catch (Exception $ex) {
- alert::recError("Erreur lors de la modification de l'utilisateur");
- header("Location: /user-" . $_input["id"] . ".html");
- exit();
- }
- }
- /**
- * Récupère les tags associés à un utilisateur.
- *
- * @param float $_idUser Identifiant de l'utilisateur.
- * @return string|null Liste des tags sous forme de chaîne ou NULL si aucun tag.
- */
- static public function getTags(float $_idUser)
- {
- db::query("SELECT "
- . "" . DB_T_TAGS . ".label "
- . "FROM " . DB_T_USER_TAGS . " "
- . "INNER JOIN " . DB_T_TAGS . " ON " . DB_T_TAGS . ".id = " . DB_T_USER_TAGS . ".id_tags "
- . "WHERE " . DB_T_USER_TAGS . ".id_user = :id "
- . "ORDER BY " . DB_T_USER_TAGS . ".creer");
- db::bind(':id', $_idUser);
- $tmp = db::resultset();
- if (isset($tmp[0])) {
- $return = NULL;
- foreach ($tmp as $value) {
- $return .= $value["label"] . ",";
- }
- $return = substr($return, 0, -1);
- return $return;
- } else {
- return NULL;
- }
- }
- /**
- * Récupère les identifiants des tags associés à un utilisateur.
- *
- * @param float $_idUser Identifiant de l'utilisateur.
- * @return array|null Liste des identifiants des tags ou NULL si aucun tag.
- */
- static public function getIdTags(float $_idUser)
- {
- db::query("SELECT "
- . "" . DB_T_USER_TAGS . ".id_tags "
- . "FROM " . DB_T_USER_TAGS . " "
- . "WHERE " . DB_T_USER_TAGS . ".id_user = :id "
- . "ORDER BY " . DB_T_USER_TAGS . ".creer");
- db::bind(':id', $_idUser);
- $tmp = db::resultset();
- if (isset($tmp[0])) {
- $return = [];
- foreach ($tmp as $value) {
- $return[] = $value["id_tags"];
- }
- return $return;
- } else {
- return NULL;
- }
- }
- /**
- * Ajoute des tags à un utilisateur.
- *
- * @param float $_idUser Identifiant de l'utilisateur.
- * @param string|null $_tags Liste des tags sous forme de chaîne (séparés par des virgules).
- * @return bool TRUE si les tags sont ajoutés avec succès, FALSE en cas d'échec.
- */
- private static function addTags(float $_idUser, ?string $_tags = NULL)
- {
- db::query("DELETE FROM " . DB_T_USER_TAGS . " WHERE id_user = :id_user");
- db::bind(':id_user', $_idUser);
- db::execute();
- if ($_tags != NULL) {
- $tags = explode(",", $_tags);
- $sqlMaj = "";
- foreach ($tags as $tag) {
- $sqlMaj .= " (:id_user, " . $tag . "),";
- }
- $sqlMaj = substr($sqlMaj, 0, -1);
- db::query("INSERT INTO " . DB_T_USER_TAGS . " (id_user, id_tags) VALUES" . $sqlMaj);
- db::bind(':id_user', $_idUser);
- try {
- db::execute();
- return TRUE;
- } catch (Exception $ex) {
- return FALSE;
- }
- }
- }
- /**
- * Marque un utilisateur comme supprimé.
- *
- * @param int $_id Identifiant de l'utilisateur.
- */
- public static function deleteUser(int $_id)
- {
- db::query("UPDATE " . DB_T_USER . " SET deleted = 1 WHERE id = :id");
- db::bind(':id', $_id);
- try {
- db::execute();
- } catch (Exception $ex) {
- alert::recError("Erreur lors de la suppression");
- header("Location: /user-" . $_id . ".html");
- exit();
- }
- }
- /**
- * Restaure un utilisateur précédemment supprimé.
- *
- * @param int $_id Identifiant de l'utilisateur.
- */
- public static function restoreUser(int $_id)
- {
- db::query("UPDATE " . DB_T_USER . " SET deleted = 0 WHERE id = :id");
- db::bind(':id', $_id);
- try {
- db::execute();
- } catch (Exception $ex) {
- alert::recError("Erreur lors de la restauration");
- header("Location: /user-" . $_id . ".html");
- exit();
- }
- }
- /**
- * Vérifie si l'utilisateur a activé la double authentification.
- *
- * @return bool TRUE si la double authentification est activée, FALSE sinon.
- */
- static public function checkSecur()
- {
- db::query("SELECT googleAuthenticator FROM " . DB_T_USER . " WHERE id = :id");
- db::bind(':id', session::getId());
- return db::single()["googleAuthenticator"] == 1 ? TRUE : FALSE;
- }
- /**
- * Affiche un message de sécurité si la double authentification n'est pas activée.
- */
- static public function printIsSecur()
- {
- if (ALERT_AUTHENTICATOR == TRUE) {
- $_SESSION["CALLOUT"] ??= 0;
- if (self::checkSecur() == FALSE and $_SESSION["CALLOUT"] < NB_ALERT_AUTHENTICATOR) {
- $callout = [
- "type" => "danger",
- "size" => "tiny",
- "p" => "Pour sécuriser l'accès au CMS, il est fortement recommandé d'activer la double authentification (Google Authenticator) sur votre profil. Pour l'activer sur votre profil en <a href=\"/user.html\">cliquant ici</a>.",
- ];
- callout::print($callout);
- $_SESSION["CALLOUT"]++;
- }
- }
- }
- /**
- * Vérifie si le 2FA est en attente de validation pour un utilisateur.
- *
- * @param int $_id Identifiant de l'utilisateur.
- * @return bool TRUE si le 2FA est en attente de validation, FALSE sinon.
- */
- public static function is2FAPending(int $_id): bool
- {
- try {
- db::query("SELECT googleAuthenticatorPending FROM " . DB_T_USER . " WHERE id = :id");
- db::bind(':id', $_id);
- $result = db::single();
- return isset($result["googleAuthenticatorPending"]) && $result["googleAuthenticatorPending"] == 1;
- } catch (Exception $ex) {
- // La colonne n'existe pas encore, retourner false
- return false;
- }
- }
- /**
- * Définit le 2FA en mode pending (en attente de validation du premier code).
- *
- * @param int $_id Identifiant de l'utilisateur.
- * @return bool TRUE si la mise à jour est réussie, FALSE sinon.
- */
- public static function set2FAPending(int $_id): bool
- {
- db::query("UPDATE " . DB_T_USER . " SET googleAuthenticatorPending = 1, googleAuthenticator = 0 WHERE id = :id");
- db::bind(':id', $_id);
- try {
- db::execute();
- return true;
- } catch (Exception $ex) {
- return false;
- }
- }
- /**
- * Valide le code TOTP et active définitivement le 2FA.
- *
- * @param int $_id Identifiant de l'utilisateur.
- * @param string $_code Code TOTP à vérifier.
- * @return array Résultat de la validation avec status et message.
- */
- public static function validate2FAActivation(int $_id, string $_code): array
- {
- // Récupérer le secret de l'utilisateur
- $secret = self::getMyGoogleAuthenticator($_id);
- if (empty($secret)) {
- return [
- "status" => "error",
- "message" => "Aucun secret Google Authenticator configuré."
- ];
- }
- // Vérifier le code TOTP
- if (googleAuthenticator::verifyCode($secret, $_code, 1)) {
- // Code valide, activer le 2FA et supprimer le pending
- db::query("UPDATE " . DB_T_USER . " SET googleAuthenticator = 1, googleAuthenticatorPending = 0 WHERE id = :id");
- db::bind(':id', $_id);
- try {
- db::execute();
- return [
- "status" => "success",
- "message" => "La double authentification a été activée avec succès."
- ];
- } catch (Exception $ex) {
- return [
- "status" => "error",
- "message" => "Erreur lors de l'activation de la double authentification."
- ];
- }
- } else {
- return [
- "status" => "error",
- "message" => "Code invalide. Veuillez réessayer."
- ];
- }
- }
- /**
- * Annule le mode pending du 2FA.
- *
- * @param int $_id Identifiant de l'utilisateur.
- * @return bool TRUE si l'annulation est réussie, FALSE sinon.
- */
- public static function cancel2FAPending(int $_id): bool
- {
- db::query("UPDATE " . DB_T_USER . " SET googleAuthenticatorPending = 0 WHERE id = :id");
- db::bind(':id', $_id);
- try {
- db::execute();
- return true;
- } catch (Exception $ex) {
- return false;
- }
- }
- }
|