|
@@ -14,6 +14,7 @@ class user {
|
|
|
. "" . DB_T_USER . ".nom, "
|
|
. "" . DB_T_USER . ".nom, "
|
|
|
. "" . DB_T_USER . ".cree, "
|
|
. "" . DB_T_USER . ".cree, "
|
|
|
. "" . DB_T_USER . ".last_connect, "
|
|
. "" . DB_T_USER . ".last_connect, "
|
|
|
|
|
+ . "" . DB_T_USER . ".googleAuthenticator, "
|
|
|
. "" . DB_T_USER . ".actif, "
|
|
. "" . DB_T_USER . ".actif, "
|
|
|
. "" . DB_T_USER . ".id_type, "
|
|
. "" . DB_T_USER . ".id_type, "
|
|
|
. "" . DB_T_USER_TYPE . ".type "
|
|
. "" . DB_T_USER_TYPE . ".type "
|
|
@@ -33,6 +34,7 @@ class user {
|
|
|
. "" . DB_T_USER . ".nom, "
|
|
. "" . DB_T_USER . ".nom, "
|
|
|
. "" . DB_T_USER . ".cree, "
|
|
. "" . DB_T_USER . ".cree, "
|
|
|
. "" . DB_T_USER . ".last_connect, "
|
|
. "" . DB_T_USER . ".last_connect, "
|
|
|
|
|
+ . "" . DB_T_USER . ".googleAuthenticator, "
|
|
|
. "" . DB_T_USER . ".actif, "
|
|
. "" . DB_T_USER . ".actif, "
|
|
|
. "" . DB_T_USER . ".id_type, "
|
|
. "" . DB_T_USER . ".id_type, "
|
|
|
. "" . DB_T_USER_TYPE . ".type "
|
|
. "" . DB_T_USER_TYPE . ".type "
|
|
@@ -41,13 +43,28 @@ class user {
|
|
|
return db::resultset();
|
|
return db::resultset();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ 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"];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public static function connect(array $_input) {
|
|
public static function connect(array $_input) {
|
|
|
$return = NULL;
|
|
$return = NULL;
|
|
|
if (isset($_input["email"]) AND isset($_input["password"])) {
|
|
if (isset($_input["email"]) AND isset($_input["password"])) {
|
|
|
- db::query("SELECT id, email, password, prenom, nom, id_type, actif FROM " . DB_T_USER . " WHERE email = :email");
|
|
|
|
|
|
|
+ db::query("SELECT id, email, password, prenom, nom, id_type, googleAuthenticator, googleAuthenticatorSecret, actif FROM " . DB_T_USER . " WHERE email = :email");
|
|
|
db::bind(':email', $_input["email"]);
|
|
db::bind(':email', $_input["email"]);
|
|
|
$row = db::single();
|
|
$row = db::single();
|
|
|
|
|
|
|
|
|
|
+ if($row["googleAuthenticator"] == 1){
|
|
|
|
|
+ if(googleAuthenticator::verifyCode($row["googleAuthenticatorSecret"], $_input["authenticator"], 1) == FALSE){
|
|
|
|
|
+ $row["id"] = NULL;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if (isset($row["id"])) {
|
|
if (isset($row["id"])) {
|
|
|
if ($row["actif"] == 0) {
|
|
if ($row["actif"] == 0) {
|
|
|
alert::recError("Votre compte est désactivé");
|
|
alert::recError("Votre compte est désactivé");
|
|
@@ -57,6 +74,7 @@ class user {
|
|
|
"id" => $row["id"],
|
|
"id" => $row["id"],
|
|
|
"prenom" => $row["prenom"],
|
|
"prenom" => $row["prenom"],
|
|
|
"nom" => $row["nom"],
|
|
"nom" => $row["nom"],
|
|
|
|
|
+ "googleAuthenticator" => $row["googleAuthenticator"],
|
|
|
"idType" => $row["id_type"],
|
|
"idType" => $row["id_type"],
|
|
|
"email" => $row["email"],
|
|
"email" => $row["email"],
|
|
|
"actif" => $row["actif"]
|
|
"actif" => $row["actif"]
|
|
@@ -84,6 +102,7 @@ class user {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public static function add_user(array $_input){
|
|
public static function add_user(array $_input){
|
|
|
|
|
+
|
|
|
db::query("INSERT INTO " . DB_T_USER . " "
|
|
db::query("INSERT INTO " . DB_T_USER . " "
|
|
|
. "(email, password, prenom, nom, id_type, actif) "
|
|
. "(email, password, prenom, nom, id_type, actif) "
|
|
|
. "VALUES (:email, :password, :prenom, :nom, :id_type, :actif)");
|
|
. "VALUES (:email, :password, :prenom, :nom, :id_type, :actif)");
|
|
@@ -91,6 +110,7 @@ class user {
|
|
|
db::bind(':password', md5($_input["password"]));
|
|
db::bind(':password', md5($_input["password"]));
|
|
|
db::bind(':prenom', $_input["prenom"]);
|
|
db::bind(':prenom', $_input["prenom"]);
|
|
|
db::bind(':nom', $_input["nom"]);
|
|
db::bind(':nom', $_input["nom"]);
|
|
|
|
|
+ db::bind(':googleAuthenticatorSecret', googleAuthenticator::createSecret());
|
|
|
db::bind(':id_type', $_input["id_type"]);
|
|
db::bind(':id_type', $_input["id_type"]);
|
|
|
db::bind(':actif', $_input["actif"]);
|
|
db::bind(':actif', $_input["actif"]);
|
|
|
|
|
|
|
@@ -123,10 +143,11 @@ class user {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- db::query("UPDATE " . DB_T_USER . " SET email = :email, prenom = :prenom, nom = :nom, id_type = :id_type, actif = :actif WHERE id = :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(':email', $_input["email"]);
|
|
|
db::bind(':prenom', $_input["prenom"]);
|
|
db::bind(':prenom', $_input["prenom"]);
|
|
|
db::bind(':nom', $_input["nom"]);
|
|
db::bind(':nom', $_input["nom"]);
|
|
|
|
|
+ db::bind(':googleAuthenticator', $_input["googleAuthenticator"]);
|
|
|
db::bind(':id_type', $_input["id_type"]);
|
|
db::bind(':id_type', $_input["id_type"]);
|
|
|
db::bind(':actif', $_input["actif"]);
|
|
db::bind(':actif', $_input["actif"]);
|
|
|
db::bind(':id', $_input["id"]);
|
|
db::bind(':id', $_input["id"]);
|