1
0
mirror of https://github.com/devcode-it/openstamanager.git synced 2024-12-27 08:12:47 +01:00

Fix login API

This commit is contained in:
Luca 2018-05-15 15:15:24 +02:00
parent c8a6f2d4d2
commit 82c117d94b
2 changed files with 9 additions and 2 deletions

View File

@ -62,7 +62,14 @@ try {
break; break;
} }
} catch (InvalidArgumentException $e) { } 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) { } catch (Exception $e) {
$result = API::error('serverError'); $result = API::error('serverError');
} }

View File

@ -3,7 +3,7 @@
switch ($resource) { switch ($resource) {
case 'login': case 'login':
// Controllo sulle credenziali // Controllo sulle credenziali
if (Auth::getInstance()->attempt($request['username'], $request['password'])) { if (Auth::getInstance()->attempt(post('username'), post('password'))) {
$token = Auth::getInstance()->getToken(); $token = Auth::getInstance()->getToken();
// Informazioni da restituire tramite l'API // Informazioni da restituire tramite l'API