mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Support validating OAuth token
This commit is contained in:
parent
08a07f09ed
commit
a1fcc3519a
@ -4,6 +4,8 @@ use Auth;
|
||||
use Utils;
|
||||
use Response;
|
||||
use Cache;
|
||||
use Socialite;
|
||||
use Exception;
|
||||
use App\Models\Account;
|
||||
use App\Ninja\Repositories\AccountRepository;
|
||||
use Illuminate\Http\Request;
|
||||
@ -181,4 +183,18 @@ class AccountApiController extends BaseAPIController
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function validateOauthToken(Request $request)
|
||||
{
|
||||
$token = $request->input('token');
|
||||
$provider = $request->input('provider');
|
||||
|
||||
try {
|
||||
$user = Socialite::driver($provider)->userFromToken($token);
|
||||
} catch (Exception $exception) {
|
||||
return $this->response($exception->getMessage());
|
||||
}
|
||||
|
||||
return $user ? RESULT_SUCCESS : RESULT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
@ -308,6 +308,7 @@ Route::group(['middleware' => 'api', 'prefix' => 'api/v1'], function()
|
||||
Route::post('update_notifications', 'AccountApiController@updatePushNotifications');
|
||||
Route::get('dashboard', 'DashboardApiController@index');
|
||||
Route::resource('documents', 'DocumentAPIController');
|
||||
Route::post('validate_outh_token', 'AccountApiController@validateOauthToken');
|
||||
|
||||
// Vendor
|
||||
Route::resource('vendors', 'VendorApiController');
|
||||
|
Loading…
x
Reference in New Issue
Block a user