This commit is contained in:
thaaoblues 2024-04-11 22:20:03 +02:00
parent 8fd771a345
commit 7c43151c1f
3 changed files with 9 additions and 3 deletions

View file

@ -59,7 +59,7 @@
case 'test_auth': case 'test_auth':
if($_SESSION["utilisateur_authentifie"] == true){ if($_SESSION["utilisateur_authentifie"] == true){
echo(json_encode(["status"=> "1","msg"=> "Utilisateur bien authentifié."])); echo(json_encode(["status"=> "1","msg"=> "Bonjour ".$_SESSION["unsername"]." !"]));
}else{ }else{
echo(json_encode(["status"=> "4","msg"=> "Utilisateur non authentifié."])); echo(json_encode(["status"=> "4","msg"=> "Utilisateur non authentifié."]));
} }

View file

@ -6,11 +6,13 @@ async function test_auth(){
// fonction de test, innutile en prod // fonction de test, innutile en prod
async function authenticate_user(){ async function authenticate_user(){
resp = await fetch("api.php/auth"); /*resp = await fetch("api.php/auth");
data = await resp.json(); data = await resp.json();
if(data.status == 1){ if(data.status == 1){
document.getElementById("user_status").innerText = data["msg"]; document.getElementById("user_status").innerText = data["msg"];
} }*/
document.location.href = "session_verif.php";
} }

View file

@ -34,6 +34,7 @@ if (isset($_REQUEST['logout'])) {
} }
$_SESSION["utilisateur_authentifie"] = true; $_SESSION["utilisateur_authentifie"] = true;
$_SESSION["username"] = phpCAS::getUser();
function verifier_session(){ function verifier_session(){
@ -41,6 +42,9 @@ function verifier_session(){
//return json_encode(["status"=>1,"msg"=>"Bonjour !"]); //return json_encode(["status"=>1,"msg"=>"Bonjour !"]);
} }
// fermez les yeux ici, j'ai pas la foi de faire un admin panel en entier
$ADMINS = array("mougnibas","rebillar"); $ADMINS = array("mougnibas","rebillar");
function admin_seulement(){ function admin_seulement(){