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'); }
<?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;