diff --git a/api/index.php b/api/index.php index 3ce16569c..8948e0e5a 100644 --- a/api/index.php +++ b/api/index.php @@ -62,7 +62,14 @@ try { break; } } catch (InvalidArgumentException $e) { - $result = API::error('unauthorized'); + + if (Auth::getInstance()->attempt(post('username'), post('password'))) { + $token = Auth::getInstance()->getToken(); + $result = $token; + }else{ + $result = API::error('unauthorized'); + } + } catch (Exception $e) { $result = API::error('serverError'); } diff --git a/modules/utenti/api/create.php b/modules/utenti/api/create.php index 905a134c1..2cdf34920 100644 --- a/modules/utenti/api/create.php +++ b/modules/utenti/api/create.php @@ -3,7 +3,7 @@ switch ($resource) { case 'login': // Controllo sulle credenziali - if (Auth::getInstance()->attempt($request['username'], $request['password'])) { + if (Auth::getInstance()->attempt(post('username'), post('password'))) { $token = Auth::getInstance()->getToken(); // Informazioni da restituire tramite l'API