예제 #1
0
 public function testChangePassword()
 {
     $auth = new Authentification();
     $auth->add_user('toto', 'toto');
     $auth->change_password('toto', 'toto', 'titi');
     $auth->connect('toto', 'titi');
     $this->assertTrue($auth->is_connected()['loggedIn']);
     $auth->deconnect();
     $auth->change_password('toto', 'motDePassFaux', 'tata');
     $auth->connect('toto', 'tata');
     $this->assertFalse($auth->is_connected()['loggedIn']);
     $auth->deconnect();
     $auth->remove_user('toto');
 }
예제 #2
0
    session_start();
}
require_once '../../classes/admin.php';
require_once '../../classes/authentification.php';
require_once '../../classes/tasks.php';
$auth = new Authentification();
$admin = new Admin();
$id_connected = $auth->is_connected();
$params = json_decode(file_get_contents('php://input'), true);
if (!$id_connected['admin']) {
    return;
}
switch ($params['action']) {
    //--------------- ADD_USER ------------------
    case 'add_user':
        echo json_encode($auth->add_user($params['login'], "password"));
        if (isset($params['isAdmin']) && $params['isAdmin'] == 'true') {
            $admin->add_admin($params['login']);
        }
        break;
        //--------------- SET_ADMIN ------------------
    //--------------- SET_ADMIN ------------------
    case 'set_admin':
        if ($params['isAdmin'] == 'true') {
            echo json_encode($admin->add_admin($params['login']));
        } else {
            echo json_encode($admin->remove_admin($params['login']));
        }
        break;
        //--------------- GET_USERS ------------------
    //--------------- GET_USERS ------------------