@@ -9,40 +9,40 @@ |
||
| 9 | 9 | |
| 10 | 10 | class ReportController extends BaseApiController |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * Path of the model resource |
|
| 14 | - * |
|
| 15 | - * @var string |
|
| 16 | - */ |
|
| 17 | - protected $modelResource = 'App\Modules\Reporting\Http\Resources\Report'; |
|
| 12 | + /** |
|
| 13 | + * Path of the model resource |
|
| 14 | + * |
|
| 15 | + * @var string |
|
| 16 | + */ |
|
| 17 | + protected $modelResource = 'App\Modules\Reporting\Http\Resources\Report'; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * List of all route actions that the base api controller |
|
| 21 | - * will skip permissions check for them. |
|
| 22 | - * @var array |
|
| 23 | - */ |
|
| 24 | - protected $skipPermissionCheck = ['getReport']; |
|
| 19 | + /** |
|
| 20 | + * List of all route actions that the base api controller |
|
| 21 | + * will skip permissions check for them. |
|
| 22 | + * @var array |
|
| 23 | + */ |
|
| 24 | + protected $skipPermissionCheck = ['getReport']; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Init new object. |
|
| 28 | - * |
|
| 29 | - * @param ReportService $service |
|
| 30 | - * @return void |
|
| 31 | - */ |
|
| 32 | - public function __construct(ReportService $service) |
|
| 33 | - { |
|
| 34 | - parent::__construct($service); |
|
| 35 | - } |
|
| 26 | + /** |
|
| 27 | + * Init new object. |
|
| 28 | + * |
|
| 29 | + * @param ReportService $service |
|
| 30 | + * @return void |
|
| 31 | + */ |
|
| 32 | + public function __construct(ReportService $service) |
|
| 33 | + { |
|
| 34 | + parent::__construct($service); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Render the given servicert name with the given conditions. |
|
| 39 | - * |
|
| 40 | - * @param Request $request |
|
| 41 | - * @param string $reportName Name of the requested servicert |
|
| 42 | - * @return \Illuminate\Http\Response |
|
| 43 | - */ |
|
| 44 | - public function getReport(Request $request, $reportName) |
|
| 45 | - { |
|
| 46 | - return new ViewResource($this->service->getReport($reportName, $request->all(), $request->query('perPage'))); |
|
| 47 | - } |
|
| 37 | + /** |
|
| 38 | + * Render the given servicert name with the given conditions. |
|
| 39 | + * |
|
| 40 | + * @param Request $request |
|
| 41 | + * @param string $reportName Name of the requested servicert |
|
| 42 | + * @return \Illuminate\Http\Response |
|
| 43 | + */ |
|
| 44 | + public function getReport(Request $request, $reportName) |
|
| 45 | + { |
|
| 46 | + return new ViewResource($this->service->getReport($reportName, $request->all(), $request->query('perPage'))); |
|
| 47 | + } |
|
| 48 | 48 | } |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | |
| 3 | 3 | namespace App\Providers; |
| 4 | 4 | |
| 5 | -use Illuminate\Support\ServiceProvider; |
|
| 5 | +use Illuminate\Support\ServiceProvider; |
|
| 6 | 6 | use Illuminate\Support\Facades\Broadcast; |
| 7 | 7 | |
| 8 | 8 | class BroadcastServiceProvider extends ServiceProvider |
@@ -7,15 +7,15 @@ |
||
| 7 | 7 | |
| 8 | 8 | class BroadcastServiceProvider extends ServiceProvider |
| 9 | 9 | {
|
| 10 | - /** |
|
| 11 | - * Bootstrap any application services. |
|
| 12 | - * |
|
| 13 | - * @return void |
|
| 14 | - */ |
|
| 15 | - public function boot() |
|
| 16 | - {
|
|
| 17 | - Broadcast::routes(['middleware' => ['auth:api']]); |
|
| 10 | + /** |
|
| 11 | + * Bootstrap any application services. |
|
| 12 | + * |
|
| 13 | + * @return void |
|
| 14 | + */ |
|
| 15 | + public function boot() |
|
| 16 | + {
|
|
| 17 | + Broadcast::routes(['middleware' => ['auth:api']]); |
|
| 18 | 18 | |
| 19 | - require base_path('routes/channels.php');
|
|
| 20 | - } |
|
| 19 | + require base_path('routes/channels.php');
|
|
| 20 | + } |
|
| 21 | 21 | } |
@@ -16,7 +16,6 @@ |
||
| 16 | 16 | * |
| 17 | 17 | * @param Session $session |
| 18 | 18 | * @param Auth $auth |
| 19 | - * @param Errors $errors |
|
| 20 | 19 | * |
| 21 | 20 | * @return void |
| 22 | 21 | */ |
@@ -8,53 +8,53 @@ |
||
| 8 | 8 | |
| 9 | 9 | class UpdateLocaleAndTimezone |
| 10 | 10 | { |
| 11 | - protected $session; |
|
| 12 | - protected $auth; |
|
| 11 | + protected $session; |
|
| 12 | + protected $auth; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Init new object. |
|
| 16 | - * |
|
| 17 | - * @param Session $session |
|
| 18 | - * @param Auth $auth |
|
| 19 | - * @param Errors $errors |
|
| 20 | - * |
|
| 21 | - * @return void |
|
| 22 | - */ |
|
| 23 | - public function __construct(Session $session, Auth $auth) |
|
| 24 | - { |
|
| 25 | - $this->session = $session; |
|
| 26 | - $this->auth = $auth; |
|
| 27 | - } |
|
| 14 | + /** |
|
| 15 | + * Init new object. |
|
| 16 | + * |
|
| 17 | + * @param Session $session |
|
| 18 | + * @param Auth $auth |
|
| 19 | + * @param Errors $errors |
|
| 20 | + * |
|
| 21 | + * @return void |
|
| 22 | + */ |
|
| 23 | + public function __construct(Session $session, Auth $auth) |
|
| 24 | + { |
|
| 25 | + $this->session = $session; |
|
| 26 | + $this->auth = $auth; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Handle an incoming request. |
|
| 31 | - * |
|
| 32 | - * @param \Illuminate\Http\Request $request |
|
| 33 | - * @param \Closure $next |
|
| 34 | - * @return mixed |
|
| 35 | - */ |
|
| 36 | - public function handle($request, Closure $next) |
|
| 37 | - { |
|
| 38 | - $update = false; |
|
| 39 | - $user = $this->auth->user(); |
|
| 40 | - if ($user) { |
|
| 41 | - $locale = $this->session->get('locale'); |
|
| 42 | - $timezone = $this->session->get('time-zone'); |
|
| 43 | - if ($locale && $locale !== 'all' && $locale !== $user->locale) { |
|
| 44 | - $user->locale = $locale; |
|
| 45 | - $update = true; |
|
| 46 | - } |
|
| 29 | + /** |
|
| 30 | + * Handle an incoming request. |
|
| 31 | + * |
|
| 32 | + * @param \Illuminate\Http\Request $request |
|
| 33 | + * @param \Closure $next |
|
| 34 | + * @return mixed |
|
| 35 | + */ |
|
| 36 | + public function handle($request, Closure $next) |
|
| 37 | + { |
|
| 38 | + $update = false; |
|
| 39 | + $user = $this->auth->user(); |
|
| 40 | + if ($user) { |
|
| 41 | + $locale = $this->session->get('locale'); |
|
| 42 | + $timezone = $this->session->get('time-zone'); |
|
| 43 | + if ($locale && $locale !== 'all' && $locale !== $user->locale) { |
|
| 44 | + $user->locale = $locale; |
|
| 45 | + $update = true; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - if ($timezone && $timezone !== $user->timezone) { |
|
| 49 | - $user->timezone = $timezone; |
|
| 50 | - $update = true; |
|
| 51 | - } |
|
| 48 | + if ($timezone && $timezone !== $user->timezone) { |
|
| 49 | + $user->timezone = $timezone; |
|
| 50 | + $update = true; |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - if ($update) { |
|
| 54 | - $user->save(); |
|
| 55 | - } |
|
| 56 | - } |
|
| 53 | + if ($update) { |
|
| 54 | + $user->save(); |
|
| 55 | + } |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - return $next($request); |
|
| 59 | - } |
|
| 58 | + return $next($request); |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -12,5 +12,5 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | Broadcast::channel('users.{id}', function ($user, $id) {
|
| 15 | - return (int) $user->id === (int) $id; |
|
| 15 | + return (int) $user->id === (int) $id; |
|
| 16 | 16 | }); |
@@ -11,6 +11,6 @@ |
||
| 11 | 11 | | |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -Broadcast::channel('users.{id}', function ($user, $id) {
|
|
| 14 | +Broadcast::channel('users.{id}', function($user, $id) {
|
|
| 15 | 15 | return (int) $user->id === (int) $id; |
| 16 | 16 | }); |
@@ -2,7 +2,7 @@ discard block |
||
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | 4 | |
| 5 | - /* |
|
| 5 | + /* |
|
| 6 | 6 | |-------------------------------------------------------------------------- |
| 7 | 7 | | Authentication Defaults |
| 8 | 8 | |-------------------------------------------------------------------------- |
@@ -13,12 +13,12 @@ discard block |
||
| 13 | 13 | | |
| 14 | 14 | */ |
| 15 | 15 | |
| 16 | - 'defaults' => [ |
|
| 17 | - 'guard' => 'web', |
|
| 18 | - 'passwords' => 'users', |
|
| 19 | - ], |
|
| 16 | + 'defaults' => [ |
|
| 17 | + 'guard' => 'web', |
|
| 18 | + 'passwords' => 'users', |
|
| 19 | + ], |
|
| 20 | 20 | |
| 21 | - /* |
|
| 21 | + /* |
|
| 22 | 22 | |-------------------------------------------------------------------------- |
| 23 | 23 | | Authentication Guards |
| 24 | 24 | |-------------------------------------------------------------------------- |
@@ -35,19 +35,19 @@ discard block |
||
| 35 | 35 | | |
| 36 | 36 | */ |
| 37 | 37 | |
| 38 | - 'guards' => [ |
|
| 39 | - 'web' => [ |
|
| 40 | - 'driver' => 'session', |
|
| 41 | - 'provider' => 'users', |
|
| 42 | - ], |
|
| 38 | + 'guards' => [ |
|
| 39 | + 'web' => [ |
|
| 40 | + 'driver' => 'session', |
|
| 41 | + 'provider' => 'users', |
|
| 42 | + ], |
|
| 43 | 43 | |
| 44 | - 'api' => [ |
|
| 45 | - 'driver' => 'passport', |
|
| 46 | - 'provider' => 'users', |
|
| 47 | - ], |
|
| 48 | - ], |
|
| 44 | + 'api' => [ |
|
| 45 | + 'driver' => 'passport', |
|
| 46 | + 'provider' => 'users', |
|
| 47 | + ], |
|
| 48 | + ], |
|
| 49 | 49 | |
| 50 | - /* |
|
| 50 | + /* |
|
| 51 | 51 | |-------------------------------------------------------------------------- |
| 52 | 52 | | User Providers |
| 53 | 53 | |-------------------------------------------------------------------------- |
@@ -64,19 +64,19 @@ discard block |
||
| 64 | 64 | | |
| 65 | 65 | */ |
| 66 | 66 | |
| 67 | - 'providers' => [ |
|
| 68 | - 'users' => [ |
|
| 69 | - 'driver' => 'eloquent', |
|
| 70 | - 'model' => App\Modules\Users\AclUser::class, |
|
| 71 | - ], |
|
| 67 | + 'providers' => [ |
|
| 68 | + 'users' => [ |
|
| 69 | + 'driver' => 'eloquent', |
|
| 70 | + 'model' => App\Modules\Users\AclUser::class, |
|
| 71 | + ], |
|
| 72 | 72 | |
| 73 | - // 'users' => [ |
|
| 74 | - // 'driver' => 'database', |
|
| 75 | - // 'table' => 'users', |
|
| 76 | - // ], |
|
| 77 | - ], |
|
| 73 | + // 'users' => [ |
|
| 74 | + // 'driver' => 'database', |
|
| 75 | + // 'table' => 'users', |
|
| 76 | + // ], |
|
| 77 | + ], |
|
| 78 | 78 | |
| 79 | - /* |
|
| 79 | + /* |
|
| 80 | 80 | |-------------------------------------------------------------------------- |
| 81 | 81 | | Resetting Passwords |
| 82 | 82 | |-------------------------------------------------------------------------- |
@@ -91,12 +91,12 @@ discard block |
||
| 91 | 91 | | |
| 92 | 92 | */ |
| 93 | 93 | |
| 94 | - 'passwords' => [ |
|
| 95 | - 'users' => [ |
|
| 96 | - 'provider' => 'users', |
|
| 97 | - 'table' => 'password_resets', |
|
| 98 | - 'expire' => 60, |
|
| 99 | - ], |
|
| 100 | - ], |
|
| 94 | + 'passwords' => [ |
|
| 95 | + 'users' => [ |
|
| 96 | + 'provider' => 'users', |
|
| 97 | + 'table' => 'password_resets', |
|
| 98 | + 'expire' => 60, |
|
| 99 | + ], |
|
| 100 | + ], |
|
| 101 | 101 | |
| 102 | 102 | ]; |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | {
|
| 26 | 26 | $this->registerPolicies(); |
| 27 | 27 | |
| 28 | - Passport::routes(function ($router) {
|
|
| 28 | + Passport::routes(function($router) {
|
|
| 29 | 29 | $router->forAuthorization(); |
| 30 | 30 | $router->forAccessTokens(); |
| 31 | 31 | $router->forPersonalAccessTokens(); |
@@ -7,31 +7,31 @@ |
||
| 7 | 7 | |
| 8 | 8 | class AuthServiceProvider extends ServiceProvider |
| 9 | 9 | {
|
| 10 | - /** |
|
| 11 | - * The policy mappings for the application. |
|
| 12 | - * |
|
| 13 | - * @var array |
|
| 14 | - */ |
|
| 15 | - protected $policies = [ |
|
| 16 | - 'App\Model' => 'App\Policies\ModelPolicy', |
|
| 17 | - ]; |
|
| 10 | + /** |
|
| 11 | + * The policy mappings for the application. |
|
| 12 | + * |
|
| 13 | + * @var array |
|
| 14 | + */ |
|
| 15 | + protected $policies = [ |
|
| 16 | + 'App\Model' => 'App\Policies\ModelPolicy', |
|
| 17 | + ]; |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Register any authentication / authorization services. |
|
| 21 | - * |
|
| 22 | - * @return void |
|
| 23 | - */ |
|
| 24 | - public function boot() |
|
| 25 | - {
|
|
| 26 | - $this->registerPolicies(); |
|
| 19 | + /** |
|
| 20 | + * Register any authentication / authorization services. |
|
| 21 | + * |
|
| 22 | + * @return void |
|
| 23 | + */ |
|
| 24 | + public function boot() |
|
| 25 | + {
|
|
| 26 | + $this->registerPolicies(); |
|
| 27 | 27 | |
| 28 | - Passport::routes(function ($router) {
|
|
| 29 | - $router->forAuthorization(); |
|
| 30 | - $router->forAccessTokens(); |
|
| 31 | - $router->forPersonalAccessTokens(); |
|
| 32 | - $router->forTransientTokens(); |
|
| 33 | - }); |
|
| 34 | - Passport::tokensExpireIn(\Carbon\Carbon::now()->addMinutes(60)); |
|
| 35 | - Passport::refreshTokensExpireIn(\Carbon\Carbon::now()->addMinutes(14400)); |
|
| 36 | - } |
|
| 28 | + Passport::routes(function ($router) {
|
|
| 29 | + $router->forAuthorization(); |
|
| 30 | + $router->forAccessTokens(); |
|
| 31 | + $router->forPersonalAccessTokens(); |
|
| 32 | + $router->forTransientTokens(); |
|
| 33 | + }); |
|
| 34 | + Passport::tokensExpireIn(\Carbon\Carbon::now()->addMinutes(60)); |
|
| 35 | + Passport::refreshTokensExpireIn(\Carbon\Carbon::now()->addMinutes(14400)); |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -5,14 +5,14 @@ |
||
| 5 | 5 | |
| 6 | 6 | class DummyService extends BaseService |
| 7 | 7 | { |
| 8 | - /** |
|
| 9 | - * Init new object. |
|
| 10 | - * |
|
| 11 | - * @param DummyRepository $repo |
|
| 12 | - * @return void |
|
| 13 | - */ |
|
| 14 | - public function __construct(DummyRepository $repo) |
|
| 15 | - { |
|
| 16 | - parent::__construct($repo); |
|
| 17 | - } |
|
| 8 | + /** |
|
| 9 | + * Init new object. |
|
| 10 | + * |
|
| 11 | + * @param DummyRepository $repo |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function __construct(DummyRepository $repo) |
|
| 15 | + { |
|
| 16 | + parent::__construct($repo); |
|
| 17 | + } |
|
| 18 | 18 | } |
@@ -6,67 +6,67 @@ |
||
| 6 | 6 | class SettingsObserver |
| 7 | 7 | { |
| 8 | 8 | |
| 9 | - public function saving($model) |
|
| 10 | - { |
|
| 11 | - // |
|
| 12 | - } |
|
| 9 | + public function saving($model) |
|
| 10 | + { |
|
| 11 | + // |
|
| 12 | + } |
|
| 13 | 13 | |
| 14 | - public function saved($model) |
|
| 15 | - { |
|
| 16 | - // |
|
| 17 | - } |
|
| 14 | + public function saved($model) |
|
| 15 | + { |
|
| 16 | + // |
|
| 17 | + } |
|
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * Prevent the creating of the settings. |
|
| 21 | - * |
|
| 22 | - * @param object $model the model beign created. |
|
| 23 | - * @return void |
|
| 24 | - */ |
|
| 25 | - public function creating($model) |
|
| 26 | - { |
|
| 27 | - \Errors::cannotCreateSetting(); |
|
| 28 | - } |
|
| 19 | + /** |
|
| 20 | + * Prevent the creating of the settings. |
|
| 21 | + * |
|
| 22 | + * @param object $model the model beign created. |
|
| 23 | + * @return void |
|
| 24 | + */ |
|
| 25 | + public function creating($model) |
|
| 26 | + { |
|
| 27 | + \Errors::cannotCreateSetting(); |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - public function created($model) |
|
| 31 | - { |
|
| 32 | - // |
|
| 33 | - } |
|
| 30 | + public function created($model) |
|
| 31 | + { |
|
| 32 | + // |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Prevent updating of the setting key. |
|
| 37 | - * |
|
| 38 | - * @param object $model the model beign updated. |
|
| 39 | - * @return void |
|
| 40 | - */ |
|
| 41 | - public function updating($model) |
|
| 42 | - { |
|
| 43 | - if ($model->getOriginal('key') !== $model->key) { |
|
| 44 | - \Errors::cannotUpdateSettingKey(); |
|
| 45 | - } |
|
| 46 | - } |
|
| 35 | + /** |
|
| 36 | + * Prevent updating of the setting key. |
|
| 37 | + * |
|
| 38 | + * @param object $model the model beign updated. |
|
| 39 | + * @return void |
|
| 40 | + */ |
|
| 41 | + public function updating($model) |
|
| 42 | + { |
|
| 43 | + if ($model->getOriginal('key') !== $model->key) { |
|
| 44 | + \Errors::cannotUpdateSettingKey(); |
|
| 45 | + } |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - public function updated($model) |
|
| 49 | - { |
|
| 50 | - // |
|
| 51 | - } |
|
| 48 | + public function updated($model) |
|
| 49 | + { |
|
| 50 | + // |
|
| 51 | + } |
|
| 52 | 52 | |
| 53 | - public function deleting($model) |
|
| 54 | - { |
|
| 55 | - // |
|
| 56 | - } |
|
| 53 | + public function deleting($model) |
|
| 54 | + { |
|
| 55 | + // |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - public function deleted($model) |
|
| 59 | - { |
|
| 60 | - // |
|
| 61 | - } |
|
| 58 | + public function deleted($model) |
|
| 59 | + { |
|
| 60 | + // |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - public function restoring($model) |
|
| 64 | - { |
|
| 65 | - // |
|
| 66 | - } |
|
| 63 | + public function restoring($model) |
|
| 64 | + { |
|
| 65 | + // |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - public function restored($model) |
|
| 69 | - { |
|
| 70 | - // |
|
| 71 | - } |
|
| 68 | + public function restored($model) |
|
| 69 | + { |
|
| 70 | + // |
|
| 71 | + } |
|
| 72 | 72 | } |
@@ -49,7 +49,7 @@ |
||
| 49 | 49 | |
| 50 | 50 | $response = \ApiConsumer::post('/oauth/token', $data); |
| 51 | 51 | |
| 52 | - if (! $response->isSuccessful()) { |
|
| 52 | + if ( ! $response->isSuccessful()) { |
|
| 53 | 53 | if ($grantType == 'refresh_token') { |
| 54 | 54 | \Errors::invalidRefreshToken(); |
| 55 | 55 | } |
@@ -7,64 +7,64 @@ |
||
| 7 | 7 | |
| 8 | 8 | class LoginProxy |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * Attempt to create an access token using user credentials. |
|
| 12 | - * |
|
| 13 | - * @param string $email |
|
| 14 | - * @param string $password |
|
| 15 | - * @return array |
|
| 16 | - */ |
|
| 17 | - public function login($email, $password) |
|
| 18 | - { |
|
| 19 | - return $this->proxy('password', [ |
|
| 20 | - 'username' => $email, |
|
| 21 | - 'password' => $password |
|
| 22 | - ]); |
|
| 23 | - } |
|
| 10 | + /** |
|
| 11 | + * Attempt to create an access token using user credentials. |
|
| 12 | + * |
|
| 13 | + * @param string $email |
|
| 14 | + * @param string $password |
|
| 15 | + * @return array |
|
| 16 | + */ |
|
| 17 | + public function login($email, $password) |
|
| 18 | + { |
|
| 19 | + return $this->proxy('password', [ |
|
| 20 | + 'username' => $email, |
|
| 21 | + 'password' => $password |
|
| 22 | + ]); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Attempt to refresh the access token using the given refresh token. |
|
| 27 | - * |
|
| 28 | - * @param string $refreshToken |
|
| 29 | - * @return array |
|
| 30 | - */ |
|
| 31 | - public function refreshToken($refreshToken) |
|
| 32 | - { |
|
| 33 | - return $this->proxy('refresh_token', [ |
|
| 34 | - 'refresh_token' => $refreshToken |
|
| 35 | - ]); |
|
| 36 | - } |
|
| 25 | + /** |
|
| 26 | + * Attempt to refresh the access token using the given refresh token. |
|
| 27 | + * |
|
| 28 | + * @param string $refreshToken |
|
| 29 | + * @return array |
|
| 30 | + */ |
|
| 31 | + public function refreshToken($refreshToken) |
|
| 32 | + { |
|
| 33 | + return $this->proxy('refresh_token', [ |
|
| 34 | + 'refresh_token' => $refreshToken |
|
| 35 | + ]); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * Proxy a request to the OAuth server. |
|
| 40 | - * |
|
| 41 | - * @param string $grantType what type of grant type should be proxied |
|
| 42 | - * @param array |
|
| 43 | - */ |
|
| 44 | - public function proxy($grantType, array $data = []) |
|
| 45 | - { |
|
| 46 | - $data = array_merge($data, [ |
|
| 47 | - 'client_id' => config('user.passport_client_id'), |
|
| 48 | - 'client_secret' => config('user.passport_client_secret'), |
|
| 49 | - 'grant_type' => $grantType |
|
| 50 | - ]); |
|
| 38 | + /** |
|
| 39 | + * Proxy a request to the OAuth server. |
|
| 40 | + * |
|
| 41 | + * @param string $grantType what type of grant type should be proxied |
|
| 42 | + * @param array |
|
| 43 | + */ |
|
| 44 | + public function proxy($grantType, array $data = []) |
|
| 45 | + { |
|
| 46 | + $data = array_merge($data, [ |
|
| 47 | + 'client_id' => config('user.passport_client_id'), |
|
| 48 | + 'client_secret' => config('user.passport_client_secret'), |
|
| 49 | + 'grant_type' => $grantType |
|
| 50 | + ]); |
|
| 51 | 51 | |
| 52 | - $response = \ApiConsumer::post('/oauth/token', $data); |
|
| 52 | + $response = \ApiConsumer::post('/oauth/token', $data); |
|
| 53 | 53 | |
| 54 | - if (! $response->isSuccessful()) { |
|
| 55 | - if ($grantType == 'refresh_token') { |
|
| 56 | - \Errors::invalidRefreshToken(); |
|
| 57 | - } |
|
| 54 | + if (! $response->isSuccessful()) { |
|
| 55 | + if ($grantType == 'refresh_token') { |
|
| 56 | + \Errors::invalidRefreshToken(); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - \Errors::loginFailed(); |
|
| 60 | - } |
|
| 59 | + \Errors::loginFailed(); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - $data = json_decode($response->getContent()); |
|
| 62 | + $data = json_decode($response->getContent()); |
|
| 63 | 63 | |
| 64 | - return [ |
|
| 65 | - 'access_token' => $data->access_token, |
|
| 66 | - 'refresh_token' => $data->refresh_token, |
|
| 67 | - 'expires_in' => $data->expires_in |
|
| 68 | - ]; |
|
| 69 | - } |
|
| 64 | + return [ |
|
| 65 | + 'access_token' => $data->access_token, |
|
| 66 | + 'refresh_token' => $data->refresh_token, |
|
| 67 | + 'expires_in' => $data->expires_in |
|
| 68 | + ]; |
|
| 69 | + } |
|
| 70 | 70 | } |