1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 12:12:48 +01:00

Added refresh method to API

This commit is contained in:
Hillel Coren 2018-07-31 09:10:16 +03:00
parent acbe5912ae
commit 83a106142f
2 changed files with 11 additions and 2 deletions

View File

@ -85,12 +85,20 @@ class AccountApiController extends BaseAPIController
}
}
private function processLogin(Request $request)
public function refresh(Request $request)
{
return $this->processLogin($request, false);
}
private function processLogin(Request $request, $createToken = true)
{
// Create a new token only if one does not already exist
$user = Auth::user();
$account = $user->account;
$this->accountRepo->createTokens($user, $request->token_name);
if ($createToken) {
$this->accountRepo->createTokens($user, $request->token_name);
}
$users = $this->accountRepo->findUsers($user, 'account.account_tokens');
$transformer = new UserAccountTransformer($account, $request->serializer, $request->token_name);

View File

@ -7,6 +7,7 @@ Route::post('register', 'AccountApiController@register');
Route::get('static', 'AccountApiController@getStaticData');
Route::get('accounts', 'AccountApiController@show');
Route::put('accounts', 'AccountApiController@update');
Route::post('refresh', 'AccountApiController@refresh');
Route::resource('clients', 'ClientApiController');
Route::resource('contacts', 'ContactApiController');