Esempio n. 1
0
<?php

if (!isset($_SESSION)) {
    session_start();
}
require_once '../../classes/admin.php';
require_once '../../classes/authentification.php';
$auth = new Authentification();
$id_connected = $auth->is_connected();
$params = json_decode(file_get_contents('php://input'), true);
switch ($params['action']) {
    //--------------- LOGIN ------------------
    case 'login':
        $login = $auth->format_login($params['login']);
        $password = $auth->format_password($params['password']);
        echo json_encode($auth->connect($login, $password));
        break;
        //--------------- LOGOUT ------------------
    //--------------- LOGOUT ------------------
    case 'logout':
        if (!$id_connected['loggedIn']) {
            return;
        }
        $auth->deconnect();
        echo "true";
        break;
        //--------------- ISCONNECTED ------------------
    //--------------- ISCONNECTED ------------------
    case 'isconnected':
        echo json_encode($auth->is_connected());
        break;