@@ -13,23 +13,23 @@ |
||
13 | 13 | |
14 | 14 | Route::group(['prefix' => 'notifications'], function () { |
15 | 15 | |
16 | - Route::group(['prefix' => 'notifications'], function () { |
|
16 | + Route::group(['prefix' => 'notifications'], function () { |
|
17 | 17 | |
18 | - Route::get('/', 'NotificationController@index'); |
|
19 | - Route::get('unread', 'NotificationController@unread'); |
|
20 | - Route::get('read/{id}', 'NotificationController@markAsRead'); |
|
21 | - Route::get('read/all', 'NotificationController@markAllAsRead'); |
|
22 | - }); |
|
18 | + Route::get('/', 'NotificationController@index'); |
|
19 | + Route::get('unread', 'NotificationController@unread'); |
|
20 | + Route::get('read/{id}', 'NotificationController@markAsRead'); |
|
21 | + Route::get('read/all', 'NotificationController@markAllAsRead'); |
|
22 | + }); |
|
23 | 23 | |
24 | - Route::group(['prefix' => 'push_notification_devices'], function () { |
|
24 | + Route::group(['prefix' => 'push_notification_devices'], function () { |
|
25 | 25 | |
26 | - Route::get('/', 'PushNotificationDeviceController@index'); |
|
27 | - Route::get('/{id}', 'PushNotificationDeviceController@find'); |
|
28 | - Route::post('/', 'PushNotificationDeviceController@insert'); |
|
29 | - Route::put('/', 'PushNotificationDeviceController@update'); |
|
30 | - Route::delete('/{id}', 'PushNotificationDeviceController@delete'); |
|
31 | - Route::get('list/deleted', 'PushNotificationDeviceController@deleted'); |
|
32 | - Route::patch('restore/{id}', 'PushNotificationDeviceController@restore'); |
|
33 | - Route::post('register/device', 'PushNotificationDeviceController@registerDevice'); |
|
34 | - }); |
|
26 | + Route::get('/', 'PushNotificationDeviceController@index'); |
|
27 | + Route::get('/{id}', 'PushNotificationDeviceController@find'); |
|
28 | + Route::post('/', 'PushNotificationDeviceController@insert'); |
|
29 | + Route::put('/', 'PushNotificationDeviceController@update'); |
|
30 | + Route::delete('/{id}', 'PushNotificationDeviceController@delete'); |
|
31 | + Route::get('list/deleted', 'PushNotificationDeviceController@deleted'); |
|
32 | + Route::patch('restore/{id}', 'PushNotificationDeviceController@restore'); |
|
33 | + Route::post('register/device', 'PushNotificationDeviceController@registerDevice'); |
|
34 | + }); |
|
35 | 35 | }); |
@@ -11,9 +11,9 @@ discard block |
||
11 | 11 | | |
12 | 12 | */ |
13 | 13 | |
14 | -Route::group(['prefix' => 'notifications'], function () { |
|
14 | +Route::group(['prefix' => 'notifications'], function() { |
|
15 | 15 | |
16 | - Route::group(['prefix' => 'notifications'], function () { |
|
16 | + Route::group(['prefix' => 'notifications'], function() { |
|
17 | 17 | |
18 | 18 | Route::get('/', 'NotificationController@index'); |
19 | 19 | Route::get('unread', 'NotificationController@unread'); |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | Route::get('read/all', 'NotificationController@markAllAsRead'); |
22 | 22 | }); |
23 | 23 | |
24 | - Route::group(['prefix' => 'push_notification_devices'], function () { |
|
24 | + Route::group(['prefix' => 'push_notification_devices'], function() { |
|
25 | 25 | |
26 | 26 | Route::get('/', 'PushNotificationDeviceController@index'); |
27 | 27 | Route::get('/{id}', 'PushNotificationDeviceController@find'); |
@@ -6,16 +6,16 @@ |
||
6 | 6 | |
7 | 7 | class NotificationsDatabaseSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - $this->call(ClearDataSeeder::class); |
|
17 | - $this->call(NotificationsTableSeeder::class); |
|
18 | - $this->call(PushNotificationDevicesTableSeeder::class); |
|
19 | - $this->call(AssignRelationsSeeder::class); |
|
20 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $this->call(ClearDataSeeder::class); |
|
17 | + $this->call(NotificationsTableSeeder::class); |
|
18 | + $this->call(PushNotificationDevicesTableSeeder::class); |
|
19 | + $this->call(AssignRelationsSeeder::class); |
|
20 | + } |
|
21 | 21 | } |
@@ -6,46 +6,46 @@ |
||
6 | 6 | |
7 | 7 | class NotificationsTableSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - /** |
|
17 | - * Insert the permissions related to settings table. |
|
18 | - */ |
|
19 | - \DB::table('permissions')->insert( |
|
20 | - [ |
|
21 | - /** |
|
22 | - * notifications model permissions. |
|
23 | - */ |
|
24 | - [ |
|
25 | - 'name' => 'all', |
|
26 | - 'model' => 'notification', |
|
27 | - 'created_at' => \DB::raw('NOW()'), |
|
28 | - 'updated_at' => \DB::raw('NOW()') |
|
29 | - ], |
|
30 | - [ |
|
31 | - 'name' => 'unread', |
|
32 | - 'model' => 'notification', |
|
33 | - 'created_at' => \DB::raw('NOW()'), |
|
34 | - 'updated_at' => \DB::raw('NOW()') |
|
35 | - ], |
|
36 | - [ |
|
37 | - 'name' => 'markAsRead', |
|
38 | - 'model' => 'notification', |
|
39 | - 'created_at' => \DB::raw('NOW()'), |
|
40 | - 'updated_at' => \DB::raw('NOW()') |
|
41 | - ], |
|
42 | - [ |
|
43 | - 'name' => 'markAllAsRead', |
|
44 | - 'model' => 'notification', |
|
45 | - 'created_at' => \DB::raw('NOW()'), |
|
46 | - 'updated_at' => \DB::raw('NOW()') |
|
47 | - ] |
|
48 | - ] |
|
49 | - ); |
|
50 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + /** |
|
17 | + * Insert the permissions related to settings table. |
|
18 | + */ |
|
19 | + \DB::table('permissions')->insert( |
|
20 | + [ |
|
21 | + /** |
|
22 | + * notifications model permissions. |
|
23 | + */ |
|
24 | + [ |
|
25 | + 'name' => 'all', |
|
26 | + 'model' => 'notification', |
|
27 | + 'created_at' => \DB::raw('NOW()'), |
|
28 | + 'updated_at' => \DB::raw('NOW()') |
|
29 | + ], |
|
30 | + [ |
|
31 | + 'name' => 'unread', |
|
32 | + 'model' => 'notification', |
|
33 | + 'created_at' => \DB::raw('NOW()'), |
|
34 | + 'updated_at' => \DB::raw('NOW()') |
|
35 | + ], |
|
36 | + [ |
|
37 | + 'name' => 'markAsRead', |
|
38 | + 'model' => 'notification', |
|
39 | + 'created_at' => \DB::raw('NOW()'), |
|
40 | + 'updated_at' => \DB::raw('NOW()') |
|
41 | + ], |
|
42 | + [ |
|
43 | + 'name' => 'markAllAsRead', |
|
44 | + 'model' => 'notification', |
|
45 | + 'created_at' => \DB::raw('NOW()'), |
|
46 | + 'updated_at' => \DB::raw('NOW()') |
|
47 | + ] |
|
48 | + ] |
|
49 | + ); |
|
50 | + } |
|
51 | 51 | } |
@@ -6,27 +6,27 @@ |
||
6 | 6 | |
7 | 7 | class AssignRelationsSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - $adminGroupId = \DB::table('groups')->where('name', 'admin')->select('id')->first()->id; |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $adminGroupId = \DB::table('groups')->where('name', 'admin')->select('id')->first()->id; |
|
17 | 17 | |
18 | - /** |
|
19 | - * Assign the permissions to the admin group. |
|
20 | - */ |
|
21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['notification', 'pushNotificationDevice'])->each(function ($permission) use ($adminGroupId) { |
|
22 | - \DB::table('groups_permissions')->insert( |
|
23 | - [ |
|
24 | - 'permission_id' => $permission->id, |
|
25 | - 'group_id' => $adminGroupId, |
|
26 | - 'created_at' => \DB::raw('NOW()'), |
|
27 | - 'updated_at' => \DB::raw('NOW()') |
|
28 | - ] |
|
29 | - ); |
|
30 | - }); |
|
31 | - } |
|
18 | + /** |
|
19 | + * Assign the permissions to the admin group. |
|
20 | + */ |
|
21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['notification', 'pushNotificationDevice'])->each(function ($permission) use ($adminGroupId) { |
|
22 | + \DB::table('groups_permissions')->insert( |
|
23 | + [ |
|
24 | + 'permission_id' => $permission->id, |
|
25 | + 'group_id' => $adminGroupId, |
|
26 | + 'created_at' => \DB::raw('NOW()'), |
|
27 | + 'updated_at' => \DB::raw('NOW()') |
|
28 | + ] |
|
29 | + ); |
|
30 | + }); |
|
31 | + } |
|
32 | 32 | } |
@@ -18,7 +18,7 @@ |
||
18 | 18 | /** |
19 | 19 | * Assign the permissions to the admin group. |
20 | 20 | */ |
21 | - \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['notification', 'pushNotificationDevice'])->each(function ($permission) use ($adminGroupId) { |
|
21 | + \DB::table('permissions')->orderBy('created_at', 'asc')->whereIn('model', ['notification', 'pushNotificationDevice'])->each(function($permission) use ($adminGroupId) { |
|
22 | 22 | \DB::table('groups_permissions')->insert( |
23 | 23 | [ |
24 | 24 | 'permission_id' => $permission->id, |
@@ -6,15 +6,15 @@ |
||
6 | 6 | |
7 | 7 | class ClearDataSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - $permissions = \DB::table('permissions')->whereIn('model', ['notification', 'pushNotificationDevice']); |
|
17 | - \DB::table('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
18 | - $permissions->delete(); |
|
19 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + $permissions = \DB::table('permissions')->whereIn('model', ['notification', 'pushNotificationDevice']); |
|
17 | + \DB::table('groups_permissions')->whereIn('permission_id', $permissions->pluck('id'))->delete(); |
|
18 | + $permissions->delete(); |
|
19 | + } |
|
20 | 20 | } |
@@ -6,64 +6,64 @@ |
||
6 | 6 | |
7 | 7 | class PushNotificationDevicesTableSeeder extends Seeder |
8 | 8 | { |
9 | - /** |
|
10 | - * Run the database seeds. |
|
11 | - * |
|
12 | - * @return void |
|
13 | - */ |
|
14 | - public function run() |
|
15 | - { |
|
16 | - /** |
|
17 | - * Insert the permissions related to settings table. |
|
18 | - */ |
|
19 | - \DB::table('permissions')->insert( |
|
20 | - [ |
|
21 | - /** |
|
22 | - * pushNotificationDevices model permissions. |
|
23 | - */ |
|
24 | - [ |
|
25 | - 'name' => 'index', |
|
26 | - 'model' => 'pushNotificationDevice', |
|
27 | - 'created_at' => \DB::raw('NOW()'), |
|
28 | - 'updated_at' => \DB::raw('NOW()') |
|
29 | - ], |
|
30 | - [ |
|
31 | - 'name' => 'find', |
|
32 | - 'model' => 'pushNotificationDevice', |
|
33 | - 'created_at' => \DB::raw('NOW()'), |
|
34 | - 'updated_at' => \DB::raw('NOW()') |
|
35 | - ], |
|
36 | - [ |
|
37 | - 'name' => 'insert', |
|
38 | - 'model' => 'pushNotificationDevice', |
|
39 | - 'created_at' => \DB::raw('NOW()'), |
|
40 | - 'updated_at' => \DB::raw('NOW()') |
|
41 | - ], |
|
42 | - [ |
|
43 | - 'name' => 'update', |
|
44 | - 'model' => 'pushNotificationDevice', |
|
45 | - 'created_at' => \DB::raw('NOW()'), |
|
46 | - 'updated_at' => \DB::raw('NOW()') |
|
47 | - ], |
|
48 | - [ |
|
49 | - 'name' => 'delete', |
|
50 | - 'model' => 'pushNotificationDevice', |
|
51 | - 'created_at' => \DB::raw('NOW()'), |
|
52 | - 'updated_at' => \DB::raw('NOW()') |
|
53 | - ], |
|
54 | - [ |
|
55 | - 'name' => 'deleted', |
|
56 | - 'model' => 'pushNotificationDevice', |
|
57 | - 'created_at' => \DB::raw('NOW()'), |
|
58 | - 'updated_at' => \DB::raw('NOW()') |
|
59 | - ], |
|
60 | - [ |
|
61 | - 'name' => 'restore', |
|
62 | - 'model' => 'pushNotificationDevice', |
|
63 | - 'created_at' => \DB::raw('NOW()'), |
|
64 | - 'updated_at' => \DB::raw('NOW()') |
|
65 | - ] |
|
66 | - ] |
|
67 | - ); |
|
68 | - } |
|
9 | + /** |
|
10 | + * Run the database seeds. |
|
11 | + * |
|
12 | + * @return void |
|
13 | + */ |
|
14 | + public function run() |
|
15 | + { |
|
16 | + /** |
|
17 | + * Insert the permissions related to settings table. |
|
18 | + */ |
|
19 | + \DB::table('permissions')->insert( |
|
20 | + [ |
|
21 | + /** |
|
22 | + * pushNotificationDevices model permissions. |
|
23 | + */ |
|
24 | + [ |
|
25 | + 'name' => 'index', |
|
26 | + 'model' => 'pushNotificationDevice', |
|
27 | + 'created_at' => \DB::raw('NOW()'), |
|
28 | + 'updated_at' => \DB::raw('NOW()') |
|
29 | + ], |
|
30 | + [ |
|
31 | + 'name' => 'find', |
|
32 | + 'model' => 'pushNotificationDevice', |
|
33 | + 'created_at' => \DB::raw('NOW()'), |
|
34 | + 'updated_at' => \DB::raw('NOW()') |
|
35 | + ], |
|
36 | + [ |
|
37 | + 'name' => 'insert', |
|
38 | + 'model' => 'pushNotificationDevice', |
|
39 | + 'created_at' => \DB::raw('NOW()'), |
|
40 | + 'updated_at' => \DB::raw('NOW()') |
|
41 | + ], |
|
42 | + [ |
|
43 | + 'name' => 'update', |
|
44 | + 'model' => 'pushNotificationDevice', |
|
45 | + 'created_at' => \DB::raw('NOW()'), |
|
46 | + 'updated_at' => \DB::raw('NOW()') |
|
47 | + ], |
|
48 | + [ |
|
49 | + 'name' => 'delete', |
|
50 | + 'model' => 'pushNotificationDevice', |
|
51 | + 'created_at' => \DB::raw('NOW()'), |
|
52 | + 'updated_at' => \DB::raw('NOW()') |
|
53 | + ], |
|
54 | + [ |
|
55 | + 'name' => 'deleted', |
|
56 | + 'model' => 'pushNotificationDevice', |
|
57 | + 'created_at' => \DB::raw('NOW()'), |
|
58 | + 'updated_at' => \DB::raw('NOW()') |
|
59 | + ], |
|
60 | + [ |
|
61 | + 'name' => 'restore', |
|
62 | + 'model' => 'pushNotificationDevice', |
|
63 | + 'created_at' => \DB::raw('NOW()'), |
|
64 | + 'updated_at' => \DB::raw('NOW()') |
|
65 | + ] |
|
66 | + ] |
|
67 | + ); |
|
68 | + } |
|
69 | 69 | } |
@@ -5,31 +5,31 @@ |
||
5 | 5 | |
6 | 6 | class PushNotificationDevices extends Migration |
7 | 7 | { |
8 | - /** |
|
9 | - * Run the migrations. |
|
10 | - * |
|
11 | - * @return void |
|
12 | - */ |
|
13 | - public function up() |
|
14 | - { |
|
15 | - Schema::create('push_notification_devices', function (Blueprint $table) { |
|
16 | - $table->increments('id'); |
|
17 | - $table->string('device_token'); |
|
18 | - $table->integer('user_id'); |
|
19 | - $table->text('access_token')->nullable(); |
|
20 | - $table->unique(array('device_token', 'user_id')); |
|
21 | - $table->softDeletes(); |
|
22 | - $table->timestamps(); |
|
23 | - }); |
|
24 | - } |
|
8 | + /** |
|
9 | + * Run the migrations. |
|
10 | + * |
|
11 | + * @return void |
|
12 | + */ |
|
13 | + public function up() |
|
14 | + { |
|
15 | + Schema::create('push_notification_devices', function (Blueprint $table) { |
|
16 | + $table->increments('id'); |
|
17 | + $table->string('device_token'); |
|
18 | + $table->integer('user_id'); |
|
19 | + $table->text('access_token')->nullable(); |
|
20 | + $table->unique(array('device_token', 'user_id')); |
|
21 | + $table->softDeletes(); |
|
22 | + $table->timestamps(); |
|
23 | + }); |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Reverse the migrations. |
|
28 | - * |
|
29 | - * @return void |
|
30 | - */ |
|
31 | - public function down() |
|
32 | - { |
|
33 | - Schema::dropIfExists('push_notifications_devices'); |
|
34 | - } |
|
26 | + /** |
|
27 | + * Reverse the migrations. |
|
28 | + * |
|
29 | + * @return void |
|
30 | + */ |
|
31 | + public function down() |
|
32 | + { |
|
33 | + Schema::dropIfExists('push_notifications_devices'); |
|
34 | + } |
|
35 | 35 | } |
@@ -6,37 +6,37 @@ |
||
6 | 6 | class AclPermission extends Model |
7 | 7 | { |
8 | 8 | |
9 | - use SoftDeletes; |
|
10 | - protected $table = 'permissions'; |
|
11 | - protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
12 | - protected $hidden = ['deleted_at']; |
|
13 | - protected $guarded = ['id']; |
|
14 | - protected $fillable = ['name', 'model']; |
|
15 | - public $searchable = ['name', 'model']; |
|
9 | + use SoftDeletes; |
|
10 | + protected $table = 'permissions'; |
|
11 | + protected $dates = ['created_at', 'updated_at', 'deleted_at']; |
|
12 | + protected $hidden = ['deleted_at']; |
|
13 | + protected $guarded = ['id']; |
|
14 | + protected $fillable = ['name', 'model']; |
|
15 | + public $searchable = ['name', 'model']; |
|
16 | 16 | |
17 | - public function getCreatedAtAttribute($value) |
|
18 | - { |
|
19 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
20 | - } |
|
17 | + public function getCreatedAtAttribute($value) |
|
18 | + { |
|
19 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
20 | + } |
|
21 | 21 | |
22 | - public function getUpdatedAtAttribute($value) |
|
23 | - { |
|
24 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
25 | - } |
|
22 | + public function getUpdatedAtAttribute($value) |
|
23 | + { |
|
24 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
25 | + } |
|
26 | 26 | |
27 | - public function getDeletedAtAttribute($value) |
|
28 | - { |
|
29 | - return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
30 | - } |
|
27 | + public function getDeletedAtAttribute($value) |
|
28 | + { |
|
29 | + return \Carbon\Carbon::parse($value)->tz(\Session::get('time-zone'))->toDateTimeString(); |
|
30 | + } |
|
31 | 31 | |
32 | - public function groups() |
|
33 | - { |
|
34 | - return $this->belongsToMany('App\Modules\Acl\AclGroup', 'groups_permissions', 'permission_id', 'group_id')->whereNull('groups_permissions.deleted_at')->withTimestamps(); |
|
35 | - } |
|
32 | + public function groups() |
|
33 | + { |
|
34 | + return $this->belongsToMany('App\Modules\Acl\AclGroup', 'groups_permissions', 'permission_id', 'group_id')->whereNull('groups_permissions.deleted_at')->withTimestamps(); |
|
35 | + } |
|
36 | 36 | |
37 | - public static function boot() |
|
38 | - { |
|
39 | - parent::boot(); |
|
40 | - AclPermission::observe(\App::make('App\Modules\Acl\ModelObservers\AclPermissionObserver')); |
|
41 | - } |
|
37 | + public static function boot() |
|
38 | + { |
|
39 | + parent::boot(); |
|
40 | + AclPermission::observe(\App::make('App\Modules\Acl\ModelObservers\AclPermissionObserver')); |
|
41 | + } |
|
42 | 42 | } |
@@ -2,77 +2,77 @@ |
||
2 | 2 | |
3 | 3 | class LoginProxy |
4 | 4 | { |
5 | - /** |
|
6 | - * Attempt to create an access token using user credentials. |
|
7 | - * |
|
8 | - * @param array $credentials |
|
9 | - * @param boolean $adminLogin |
|
10 | - * @return array |
|
11 | - */ |
|
12 | - public function login($credentials, $adminLogin = false) |
|
13 | - { |
|
14 | - $user = \Core::users()->login($credentials, $adminLogin); |
|
15 | - $tokens = $this->proxy('password', [ |
|
16 | - 'username' => $credentials['email'], |
|
17 | - 'password' => $credentials['password'] |
|
18 | - ]); |
|
5 | + /** |
|
6 | + * Attempt to create an access token using user credentials. |
|
7 | + * |
|
8 | + * @param array $credentials |
|
9 | + * @param boolean $adminLogin |
|
10 | + * @return array |
|
11 | + */ |
|
12 | + public function login($credentials, $adminLogin = false) |
|
13 | + { |
|
14 | + $user = \Core::users()->login($credentials, $adminLogin); |
|
15 | + $tokens = $this->proxy('password', [ |
|
16 | + 'username' => $credentials['email'], |
|
17 | + 'password' => $credentials['password'] |
|
18 | + ]); |
|
19 | 19 | |
20 | - return compact('user', 'tokens'); |
|
21 | - } |
|
20 | + return compact('user', 'tokens'); |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * Attempt to refresh the access token useing the given refresh token. |
|
25 | - * |
|
26 | - * @param string $refreshToken |
|
27 | - * @return array |
|
28 | - */ |
|
29 | - public function refreshToken($refreshToken) |
|
30 | - { |
|
31 | - return $this->proxy('refresh_token', [ |
|
32 | - 'refresh_token' => $refreshToken |
|
33 | - ]); |
|
34 | - } |
|
23 | + /** |
|
24 | + * Attempt to refresh the access token useing the given refresh token. |
|
25 | + * |
|
26 | + * @param string $refreshToken |
|
27 | + * @return array |
|
28 | + */ |
|
29 | + public function refreshToken($refreshToken) |
|
30 | + { |
|
31 | + return $this->proxy('refresh_token', [ |
|
32 | + 'refresh_token' => $refreshToken |
|
33 | + ]); |
|
34 | + } |
|
35 | 35 | |
36 | - /** |
|
37 | - * Proxy a request to the OAuth server. |
|
38 | - * |
|
39 | - * @param string $grantType what type of grant type should be proxied |
|
40 | - * @param array |
|
41 | - */ |
|
42 | - public function proxy($grantType, array $data = []) |
|
43 | - { |
|
44 | - $data = array_merge($data, [ |
|
45 | - 'client_id' => config('skeleton.passport_client_id'), |
|
46 | - 'client_secret' => config('skeleton.passport_client_secret'), |
|
47 | - 'grant_type' => $grantType |
|
48 | - ]); |
|
36 | + /** |
|
37 | + * Proxy a request to the OAuth server. |
|
38 | + * |
|
39 | + * @param string $grantType what type of grant type should be proxied |
|
40 | + * @param array |
|
41 | + */ |
|
42 | + public function proxy($grantType, array $data = []) |
|
43 | + { |
|
44 | + $data = array_merge($data, [ |
|
45 | + 'client_id' => config('skeleton.passport_client_id'), |
|
46 | + 'client_secret' => config('skeleton.passport_client_secret'), |
|
47 | + 'grant_type' => $grantType |
|
48 | + ]); |
|
49 | 49 | |
50 | - $response = \ApiConsumer::post('/oauth/token', $data); |
|
50 | + $response = \ApiConsumer::post('/oauth/token', $data); |
|
51 | 51 | |
52 | - if (! $response->isSuccessful()) { |
|
53 | - if ($grantType == 'refresh_token') { |
|
54 | - \ErrorHandler::invalidRefreshToken(); |
|
55 | - } |
|
52 | + if (! $response->isSuccessful()) { |
|
53 | + if ($grantType == 'refresh_token') { |
|
54 | + \ErrorHandler::invalidRefreshToken(); |
|
55 | + } |
|
56 | 56 | |
57 | - \ErrorHandler::loginFailed(); |
|
58 | - } |
|
57 | + \ErrorHandler::loginFailed(); |
|
58 | + } |
|
59 | 59 | |
60 | - $data = json_decode($response->getContent()); |
|
60 | + $data = json_decode($response->getContent()); |
|
61 | 61 | |
62 | - return [ |
|
63 | - 'access_token' => $data->access_token, |
|
64 | - 'refresh_token' => $data->refresh_token, |
|
65 | - 'expires_in' => $data->expires_in |
|
66 | - ]; |
|
67 | - } |
|
62 | + return [ |
|
63 | + 'access_token' => $data->access_token, |
|
64 | + 'refresh_token' => $data->refresh_token, |
|
65 | + 'expires_in' => $data->expires_in |
|
66 | + ]; |
|
67 | + } |
|
68 | 68 | |
69 | - /** |
|
70 | - * Logs out the user. We revoke access token and refresh token. |
|
71 | - * |
|
72 | - * @return void |
|
73 | - */ |
|
74 | - public function logout() |
|
75 | - { |
|
76 | - \Core::users()->revokeAccessToken(\Auth::user()->token()); |
|
77 | - } |
|
69 | + /** |
|
70 | + * Logs out the user. We revoke access token and refresh token. |
|
71 | + * |
|
72 | + * @return void |
|
73 | + */ |
|
74 | + public function logout() |
|
75 | + { |
|
76 | + \Core::users()->revokeAccessToken(\Auth::user()->token()); |
|
77 | + } |
|
78 | 78 | } |