| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- session_start();
- require_once "../../../env.inc.php";
- require_once DOCUMENT_ROOT."/access.inc.php";
- require_once DOCUMENT_ROOT."/conf.inc.php";
- require_once DIR_PHP_LAYOUTS . "header.php";
- if(core::ifPost("email") AND core::ifPost("password")){
- $connect = user::authenticator(core::getPost());
- if($connect["status"] == "success"){
- historique::recRef("/api/authenticator/");
- historique::add(array(
- "idType" => historique::getIdRef("CONNEXION"),
- "idUser" => $connect["id"],
- "idPage" => historique::getIdRef("/api/authenticator/"),
- "log" => $_SERVER['REMOTE_ADDR']
- ));
- // Réponse JSON en cas de succès
- echo json_encode([
- "status" => $connect["status"],
- "message" => "Login successful",
- "session_id" => session_id(),
- "type" => $connect["type"],
- "id" => $connect["id"],
- "prenom" => $connect["prenom"],
- "nom" => $connect["nom"],
- "googleAuthenticator" => $connect["googleAuthenticator"],
- "idType" => $connect["idType"],
- "email" => $connect["email"]
- ]);
- }
- else {
- // Authentification échouée
- http_response_code(401); // Code 401 Unauthorized
- echo json_encode([
- "status" => "error",
- "message" => "Invalid email or password"
- ]);
- }
- }
|