@@ -6,94 +6,94 @@ |
||
| 6 | 6 | |
| 7 | 7 | class GroupsTableSeeder 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 groups table. |
|
| 18 | - */ |
|
| 19 | - \DB::table('permissions')->insert( |
|
| 20 | - [ |
|
| 21 | - /** |
|
| 22 | - * Groups model permissions. |
|
| 23 | - */ |
|
| 24 | - [ |
|
| 25 | - 'name' => 'save', |
|
| 26 | - 'model' => 'groups', |
|
| 27 | - 'created_at' => \DB::raw('NOW()'), |
|
| 28 | - 'updated_at' => \DB::raw('NOW()') |
|
| 29 | - ], |
|
| 30 | - [ |
|
| 31 | - 'name' => 'delete', |
|
| 32 | - 'model' => 'groups', |
|
| 33 | - 'created_at' => \DB::raw('NOW()'), |
|
| 34 | - 'updated_at' => \DB::raw('NOW()') |
|
| 35 | - ], |
|
| 36 | - [ |
|
| 37 | - 'name' => 'find', |
|
| 38 | - 'model' => 'groups', |
|
| 39 | - 'created_at' => \DB::raw('NOW()'), |
|
| 40 | - 'updated_at' => \DB::raw('NOW()') |
|
| 41 | - ], |
|
| 42 | - [ |
|
| 43 | - 'name' => 'search', |
|
| 44 | - 'model' => 'groups', |
|
| 45 | - 'created_at' => \DB::raw('NOW()'), |
|
| 46 | - 'updated_at' => \DB::raw('NOW()') |
|
| 47 | - ], |
|
| 48 | - [ |
|
| 49 | - 'name' => 'list', |
|
| 50 | - 'model' => 'groups', |
|
| 51 | - 'created_at' => \DB::raw('NOW()'), |
|
| 52 | - 'updated_at' => \DB::raw('NOW()') |
|
| 53 | - ], |
|
| 54 | - [ |
|
| 55 | - 'name' => 'findby', |
|
| 56 | - 'model' => 'groups', |
|
| 57 | - 'created_at' => \DB::raw('NOW()'), |
|
| 58 | - 'updated_at' => \DB::raw('NOW()') |
|
| 59 | - ], |
|
| 60 | - [ |
|
| 61 | - 'name' => 'first', |
|
| 62 | - 'model' => 'groups', |
|
| 63 | - 'created_at' => \DB::raw('NOW()'), |
|
| 64 | - 'updated_at' => \DB::raw('NOW()') |
|
| 65 | - ], |
|
| 66 | - [ |
|
| 67 | - 'name' => 'paginate', |
|
| 68 | - 'model' => 'groups', |
|
| 69 | - 'created_at' => \DB::raw('NOW()'), |
|
| 70 | - 'updated_at' => \DB::raw('NOW()') |
|
| 71 | - ], |
|
| 72 | - [ |
|
| 73 | - 'name' => 'paginateby', |
|
| 74 | - 'model' => 'groups', |
|
| 75 | - 'created_at' => \DB::raw('NOW()'), |
|
| 76 | - 'updated_at' => \DB::raw('NOW()') |
|
| 77 | - ], |
|
| 78 | - [ |
|
| 79 | - 'name' => 'assignpermissions', |
|
| 80 | - 'model' => 'groups', |
|
| 81 | - 'created_at' => \DB::raw('NOW()'), |
|
| 82 | - 'updated_at' => \DB::raw('NOW()') |
|
| 83 | - ], |
|
| 84 | - [ |
|
| 85 | - 'name' => 'deleted', |
|
| 86 | - 'model' => 'groups', |
|
| 87 | - 'created_at' => \DB::raw('NOW()'), |
|
| 88 | - 'updated_at' => \DB::raw('NOW()') |
|
| 89 | - ], |
|
| 90 | - [ |
|
| 91 | - 'name' => 'restore', |
|
| 92 | - 'model' => 'groups', |
|
| 93 | - 'created_at' => \DB::raw('NOW()'), |
|
| 94 | - 'updated_at' => \DB::raw('NOW()') |
|
| 95 | - ] |
|
| 96 | - ] |
|
| 97 | - ); |
|
| 98 | - } |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + /** |
|
| 17 | + * Insert the permissions related to groups table. |
|
| 18 | + */ |
|
| 19 | + \DB::table('permissions')->insert( |
|
| 20 | + [ |
|
| 21 | + /** |
|
| 22 | + * Groups model permissions. |
|
| 23 | + */ |
|
| 24 | + [ |
|
| 25 | + 'name' => 'save', |
|
| 26 | + 'model' => 'groups', |
|
| 27 | + 'created_at' => \DB::raw('NOW()'), |
|
| 28 | + 'updated_at' => \DB::raw('NOW()') |
|
| 29 | + ], |
|
| 30 | + [ |
|
| 31 | + 'name' => 'delete', |
|
| 32 | + 'model' => 'groups', |
|
| 33 | + 'created_at' => \DB::raw('NOW()'), |
|
| 34 | + 'updated_at' => \DB::raw('NOW()') |
|
| 35 | + ], |
|
| 36 | + [ |
|
| 37 | + 'name' => 'find', |
|
| 38 | + 'model' => 'groups', |
|
| 39 | + 'created_at' => \DB::raw('NOW()'), |
|
| 40 | + 'updated_at' => \DB::raw('NOW()') |
|
| 41 | + ], |
|
| 42 | + [ |
|
| 43 | + 'name' => 'search', |
|
| 44 | + 'model' => 'groups', |
|
| 45 | + 'created_at' => \DB::raw('NOW()'), |
|
| 46 | + 'updated_at' => \DB::raw('NOW()') |
|
| 47 | + ], |
|
| 48 | + [ |
|
| 49 | + 'name' => 'list', |
|
| 50 | + 'model' => 'groups', |
|
| 51 | + 'created_at' => \DB::raw('NOW()'), |
|
| 52 | + 'updated_at' => \DB::raw('NOW()') |
|
| 53 | + ], |
|
| 54 | + [ |
|
| 55 | + 'name' => 'findby', |
|
| 56 | + 'model' => 'groups', |
|
| 57 | + 'created_at' => \DB::raw('NOW()'), |
|
| 58 | + 'updated_at' => \DB::raw('NOW()') |
|
| 59 | + ], |
|
| 60 | + [ |
|
| 61 | + 'name' => 'first', |
|
| 62 | + 'model' => 'groups', |
|
| 63 | + 'created_at' => \DB::raw('NOW()'), |
|
| 64 | + 'updated_at' => \DB::raw('NOW()') |
|
| 65 | + ], |
|
| 66 | + [ |
|
| 67 | + 'name' => 'paginate', |
|
| 68 | + 'model' => 'groups', |
|
| 69 | + 'created_at' => \DB::raw('NOW()'), |
|
| 70 | + 'updated_at' => \DB::raw('NOW()') |
|
| 71 | + ], |
|
| 72 | + [ |
|
| 73 | + 'name' => 'paginateby', |
|
| 74 | + 'model' => 'groups', |
|
| 75 | + 'created_at' => \DB::raw('NOW()'), |
|
| 76 | + 'updated_at' => \DB::raw('NOW()') |
|
| 77 | + ], |
|
| 78 | + [ |
|
| 79 | + 'name' => 'assignpermissions', |
|
| 80 | + 'model' => 'groups', |
|
| 81 | + 'created_at' => \DB::raw('NOW()'), |
|
| 82 | + 'updated_at' => \DB::raw('NOW()') |
|
| 83 | + ], |
|
| 84 | + [ |
|
| 85 | + 'name' => 'deleted', |
|
| 86 | + 'model' => 'groups', |
|
| 87 | + 'created_at' => \DB::raw('NOW()'), |
|
| 88 | + 'updated_at' => \DB::raw('NOW()') |
|
| 89 | + ], |
|
| 90 | + [ |
|
| 91 | + 'name' => 'restore', |
|
| 92 | + 'model' => 'groups', |
|
| 93 | + 'created_at' => \DB::raw('NOW()'), |
|
| 94 | + 'updated_at' => \DB::raw('NOW()') |
|
| 95 | + ] |
|
| 96 | + ] |
|
| 97 | + ); |
|
| 98 | + } |
|
| 99 | 99 | } |
@@ -6,18 +6,18 @@ |
||
| 6 | 6 | |
| 7 | 7 | class AclDatabaseSeeder 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(UsersTableSeeder::class); |
|
| 18 | - $this->call(GroupsTableSeeder::class); |
|
| 19 | - $this->call(PermissionsTableSeeder::class); |
|
| 20 | - $this->call(OauthClientsTableSeeder::class); |
|
| 21 | - $this->call(AssignRelationsSeeder::class); |
|
| 22 | - } |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + $this->call(ClearDataSeeder::class); |
|
| 17 | + $this->call(UsersTableSeeder::class); |
|
| 18 | + $this->call(GroupsTableSeeder::class); |
|
| 19 | + $this->call(PermissionsTableSeeder::class); |
|
| 20 | + $this->call(OauthClientsTableSeeder::class); |
|
| 21 | + $this->call(AssignRelationsSeeder::class); |
|
| 22 | + } |
|
| 23 | 23 | } |
@@ -6,82 +6,82 @@ |
||
| 6 | 6 | |
| 7 | 7 | class OauthClientsTableSeeder 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 oauthClients table. |
|
| 18 | - */ |
|
| 19 | - \DB::table('permissions')->insert( |
|
| 20 | - [ |
|
| 21 | - /** |
|
| 22 | - * Users model permissions. |
|
| 23 | - */ |
|
| 24 | - [ |
|
| 25 | - 'name' => 'list', |
|
| 26 | - 'model' => 'oauthClients', |
|
| 27 | - 'created_at' => \DB::raw('NOW()'), |
|
| 28 | - 'updated_at' => \DB::raw('NOW()') |
|
| 29 | - ], |
|
| 30 | - [ |
|
| 31 | - 'name' => 'find', |
|
| 32 | - 'model' => 'oauthClients', |
|
| 33 | - 'created_at' => \DB::raw('NOW()'), |
|
| 34 | - 'updated_at' => \DB::raw('NOW()') |
|
| 35 | - ], |
|
| 36 | - [ |
|
| 37 | - 'name' => 'search', |
|
| 38 | - 'model' => 'oauthClients', |
|
| 39 | - 'created_at' => \DB::raw('NOW()'), |
|
| 40 | - 'updated_at' => \DB::raw('NOW()') |
|
| 41 | - ], |
|
| 42 | - [ |
|
| 43 | - 'name' => 'paginate', |
|
| 44 | - 'model' => 'oauthClients', |
|
| 45 | - 'created_at' => \DB::raw('NOW()'), |
|
| 46 | - 'updated_at' => \DB::raw('NOW()') |
|
| 47 | - ], |
|
| 48 | - [ |
|
| 49 | - 'name' => 'revoke', |
|
| 50 | - 'model' => 'oauthClients', |
|
| 51 | - 'created_at' => \DB::raw('NOW()'), |
|
| 52 | - 'updated_at' => \DB::raw('NOW()') |
|
| 53 | - ], |
|
| 54 | - [ |
|
| 55 | - 'name' => 'unRevoke', |
|
| 56 | - 'model' => 'oauthClients', |
|
| 57 | - 'created_at' => \DB::raw('NOW()'), |
|
| 58 | - 'updated_at' => \DB::raw('NOW()') |
|
| 59 | - ], |
|
| 60 | - [ |
|
| 61 | - 'name' => 'first', |
|
| 62 | - 'model' => 'oauthClients', |
|
| 63 | - 'created_at' => \DB::raw('NOW()'), |
|
| 64 | - 'updated_at' => \DB::raw('NOW()') |
|
| 65 | - ], |
|
| 66 | - [ |
|
| 67 | - 'name' => 'findby', |
|
| 68 | - 'model' => 'oauthClients', |
|
| 69 | - 'created_at' => \DB::raw('NOW()'), |
|
| 70 | - 'updated_at' => \DB::raw('NOW()') |
|
| 71 | - ], |
|
| 72 | - [ |
|
| 73 | - 'name' => 'paginateby', |
|
| 74 | - 'model' => 'oauthClients', |
|
| 75 | - 'created_at' => \DB::raw('NOW()'), |
|
| 76 | - 'updated_at' => \DB::raw('NOW()') |
|
| 77 | - ], |
|
| 78 | - [ |
|
| 79 | - 'name' => 'save', |
|
| 80 | - 'model' => 'oauthClients', |
|
| 81 | - 'created_at' => \DB::raw('NOW()'), |
|
| 82 | - 'updated_at' => \DB::raw('NOW()') |
|
| 83 | - ] |
|
| 84 | - ] |
|
| 85 | - ); |
|
| 86 | - } |
|
| 9 | + /** |
|
| 10 | + * Run the database seeds. |
|
| 11 | + * |
|
| 12 | + * @return void |
|
| 13 | + */ |
|
| 14 | + public function run() |
|
| 15 | + { |
|
| 16 | + /** |
|
| 17 | + * Insert the permissions related to oauthClients table. |
|
| 18 | + */ |
|
| 19 | + \DB::table('permissions')->insert( |
|
| 20 | + [ |
|
| 21 | + /** |
|
| 22 | + * Users model permissions. |
|
| 23 | + */ |
|
| 24 | + [ |
|
| 25 | + 'name' => 'list', |
|
| 26 | + 'model' => 'oauthClients', |
|
| 27 | + 'created_at' => \DB::raw('NOW()'), |
|
| 28 | + 'updated_at' => \DB::raw('NOW()') |
|
| 29 | + ], |
|
| 30 | + [ |
|
| 31 | + 'name' => 'find', |
|
| 32 | + 'model' => 'oauthClients', |
|
| 33 | + 'created_at' => \DB::raw('NOW()'), |
|
| 34 | + 'updated_at' => \DB::raw('NOW()') |
|
| 35 | + ], |
|
| 36 | + [ |
|
| 37 | + 'name' => 'search', |
|
| 38 | + 'model' => 'oauthClients', |
|
| 39 | + 'created_at' => \DB::raw('NOW()'), |
|
| 40 | + 'updated_at' => \DB::raw('NOW()') |
|
| 41 | + ], |
|
| 42 | + [ |
|
| 43 | + 'name' => 'paginate', |
|
| 44 | + 'model' => 'oauthClients', |
|
| 45 | + 'created_at' => \DB::raw('NOW()'), |
|
| 46 | + 'updated_at' => \DB::raw('NOW()') |
|
| 47 | + ], |
|
| 48 | + [ |
|
| 49 | + 'name' => 'revoke', |
|
| 50 | + 'model' => 'oauthClients', |
|
| 51 | + 'created_at' => \DB::raw('NOW()'), |
|
| 52 | + 'updated_at' => \DB::raw('NOW()') |
|
| 53 | + ], |
|
| 54 | + [ |
|
| 55 | + 'name' => 'unRevoke', |
|
| 56 | + 'model' => 'oauthClients', |
|
| 57 | + 'created_at' => \DB::raw('NOW()'), |
|
| 58 | + 'updated_at' => \DB::raw('NOW()') |
|
| 59 | + ], |
|
| 60 | + [ |
|
| 61 | + 'name' => 'first', |
|
| 62 | + 'model' => 'oauthClients', |
|
| 63 | + 'created_at' => \DB::raw('NOW()'), |
|
| 64 | + 'updated_at' => \DB::raw('NOW()') |
|
| 65 | + ], |
|
| 66 | + [ |
|
| 67 | + 'name' => 'findby', |
|
| 68 | + 'model' => 'oauthClients', |
|
| 69 | + 'created_at' => \DB::raw('NOW()'), |
|
| 70 | + 'updated_at' => \DB::raw('NOW()') |
|
| 71 | + ], |
|
| 72 | + [ |
|
| 73 | + 'name' => 'paginateby', |
|
| 74 | + 'model' => 'oauthClients', |
|
| 75 | + 'created_at' => \DB::raw('NOW()'), |
|
| 76 | + 'updated_at' => \DB::raw('NOW()') |
|
| 77 | + ], |
|
| 78 | + [ |
|
| 79 | + 'name' => 'save', |
|
| 80 | + 'model' => 'oauthClients', |
|
| 81 | + 'created_at' => \DB::raw('NOW()'), |
|
| 82 | + 'updated_at' => \DB::raw('NOW()') |
|
| 83 | + ] |
|
| 84 | + ] |
|
| 85 | + ); |
|
| 86 | + } |
|
| 87 | 87 | } |
@@ -7,10 +7,10 @@ |
||
| 7 | 7 | |
| 8 | 8 | class PermissionsController extends BaseApiController |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * The name of the model that is used by the base api controller |
|
| 12 | - * to preform actions like (add, edit ... etc). |
|
| 13 | - * @var string |
|
| 14 | - */ |
|
| 15 | - protected $model = 'permissions'; |
|
| 10 | + /** |
|
| 11 | + * The name of the model that is used by the base api controller |
|
| 12 | + * to preform actions like (add, edit ... etc). |
|
| 13 | + * @var string |
|
| 14 | + */ |
|
| 15 | + protected $model = 'permissions'; |
|
| 16 | 16 | } |
@@ -8,282 +8,282 @@ |
||
| 8 | 8 | |
| 9 | 9 | class UsersController extends BaseApiController |
| 10 | 10 | { |
| 11 | - /** |
|
| 12 | - * The name of the model that is used by the base api controller |
|
| 13 | - * to preform actions like (add, edit ... etc). |
|
| 14 | - * @var string |
|
| 15 | - */ |
|
| 16 | - protected $model = 'users'; |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * List of all route actions that the base api controller |
|
| 20 | - * will skip permissions check for them. |
|
| 21 | - * @var array |
|
| 22 | - */ |
|
| 23 | - protected $skipPermissionCheck = ['account', 'logout', 'changePassword', 'saveProfile', 'account']; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * List of all route actions that the base api controller |
|
| 27 | - * will skip login check for them. |
|
| 28 | - * @var array |
|
| 29 | - */ |
|
| 30 | - protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendreset', 'resetpassword', 'refreshtoken', 'confirmEmail', 'resendEmailConfirmation']; |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * The validations rules used by the base api controller |
|
| 34 | - * to check before add. |
|
| 35 | - * @var array |
|
| 36 | - */ |
|
| 37 | - protected $validationRules = [ |
|
| 38 | - 'name' => 'nullable|string', |
|
| 39 | - 'email' => 'required|email|unique:users,email,{id}', |
|
| 40 | - 'password' => 'nullable|min:6' |
|
| 41 | - ]; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * The loginProxy implementation. |
|
| 45 | - * |
|
| 46 | - * @var \App\Modules\Acl\Proxy\LoginProxy |
|
| 47 | - */ |
|
| 48 | - protected $loginProxy; |
|
| 49 | - |
|
| 50 | - public function __construct(LoginProxy $loginProxy) |
|
| 51 | - { |
|
| 52 | - $this->loginProxy = $loginProxy; |
|
| 53 | - parent::__construct(); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * Return the logged in user account. |
|
| 58 | - * |
|
| 59 | - * @return \Illuminate\Http\Response |
|
| 60 | - */ |
|
| 61 | - public function account() |
|
| 62 | - { |
|
| 63 | - return \Response::json($this->repo->account($this->relations), 200); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * Block the user. |
|
| 68 | - * |
|
| 69 | - * @param integer $id Id of the user. |
|
| 70 | - * @return \Illuminate\Http\Response |
|
| 71 | - */ |
|
| 72 | - public function block($id) |
|
| 73 | - { |
|
| 74 | - return \Response::json($this->repo->block($id), 200); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Unblock the user. |
|
| 79 | - * |
|
| 80 | - * @param integer $id Id of the user. |
|
| 81 | - * @return \Illuminate\Http\Response |
|
| 82 | - */ |
|
| 83 | - public function unblock($id) |
|
| 84 | - { |
|
| 85 | - return \Response::json($this->repo->unblock($id), 200); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Logout the user. |
|
| 90 | - * |
|
| 91 | - * @return \Illuminate\Http\Response |
|
| 92 | - */ |
|
| 93 | - public function logout() |
|
| 94 | - { |
|
| 95 | - return \Response::json($this->loginProxy->logout(), 200); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * Handle a registration request. |
|
| 100 | - * |
|
| 101 | - * @param \Illuminate\Http\Request $request |
|
| 102 | - * @return \Illuminate\Http\Response |
|
| 103 | - */ |
|
| 104 | - public function register(Request $request) |
|
| 105 | - { |
|
| 106 | - $this->validate($request, [ |
|
| 107 | - 'name' => 'nullable|string', |
|
| 108 | - 'email' => 'required|email|unique:users,email,{id}', |
|
| 109 | - 'password' => 'required|min:6' |
|
| 110 | - ]); |
|
| 111 | - |
|
| 112 | - return \Response::json($this->repo->register($request->only('name', 'email', 'password')), 200); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - /** |
|
| 116 | - * Handle a login request to the application. |
|
| 117 | - * |
|
| 118 | - * @param \Illuminate\Http\Request $request |
|
| 119 | - * @return \Illuminate\Http\Response |
|
| 120 | - */ |
|
| 121 | - public function login(Request $request) |
|
| 122 | - { |
|
| 123 | - $this->validate($request, [ |
|
| 124 | - 'email' => 'required|email', |
|
| 125 | - 'password' => 'required|min:6', |
|
| 126 | - 'admin' => 'nullable|boolean' |
|
| 127 | - ]); |
|
| 128 | - |
|
| 129 | - return \Response::json($this->loginProxy->login($request->only('email', 'password'), $request->get('admin')), 200); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - /** |
|
| 133 | - * Handle a social login request of the none admin to the application. |
|
| 134 | - * |
|
| 135 | - * @param \Illuminate\Http\Request $request |
|
| 136 | - * @return \Illuminate\Http\Response |
|
| 137 | - */ |
|
| 138 | - public function loginSocial(Request $request) |
|
| 139 | - { |
|
| 140 | - $this->validate($request, [ |
|
| 141 | - 'auth_code' => 'required_without:access_token', |
|
| 142 | - 'access_token' => 'required_without:auth_code', |
|
| 143 | - 'type' => 'required|in:facebook,google' |
|
| 144 | - ]); |
|
| 145 | - |
|
| 146 | - return \Response::json($this->repo->loginSocial($request->get('auth_code'), $request->get('access_token'), $request->get('type')), 200); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * Assign the given groups to the given user. |
|
| 151 | - * |
|
| 152 | - * @param \Illuminate\Http\Request $request |
|
| 153 | - * @return \Illuminate\Http\Response |
|
| 154 | - */ |
|
| 155 | - public function assigngroups(Request $request) |
|
| 156 | - { |
|
| 157 | - $this->validate($request, [ |
|
| 158 | - 'group_ids' => 'required|exists:groups,id', |
|
| 159 | - 'user_id' => 'required|exists:users,id' |
|
| 160 | - ]); |
|
| 161 | - |
|
| 162 | - return \Response::json($this->repo->assignGroups($request->get('user_id'), $request->get('group_ids')), 200); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * Send a reset link to the given user. |
|
| 167 | - * |
|
| 168 | - * @param \Illuminate\Http\Request $request |
|
| 169 | - * @return \Illuminate\Http\Response |
|
| 170 | - */ |
|
| 171 | - public function sendreset(Request $request) |
|
| 172 | - { |
|
| 173 | - $this->validate($request, ['email' => 'required|email']); |
|
| 174 | - |
|
| 175 | - return \Response::json($this->repo->sendReset($request->get('email')), 200); |
|
| 176 | - } |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * Reset the given user's password. |
|
| 180 | - * |
|
| 181 | - * @param \Illuminate\Http\Request $request |
|
| 182 | - * @return \Illuminate\Http\Response |
|
| 183 | - */ |
|
| 184 | - public function resetpassword(Request $request) |
|
| 185 | - { |
|
| 186 | - $this->validate($request, [ |
|
| 187 | - 'token' => 'required', |
|
| 188 | - 'email' => 'required|email', |
|
| 189 | - 'password' => 'required|confirmed|min:6', |
|
| 190 | - 'password_confirmation' => 'required', |
|
| 191 | - ]); |
|
| 192 | - |
|
| 193 | - return \Response::json($this->repo->resetPassword($request->only('email', 'password', 'password_confirmation', 'token')), 200); |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * Change the logged in user password. |
|
| 198 | - * |
|
| 199 | - * @param \Illuminate\Http\Request $request |
|
| 200 | - * @return \Illuminate\Http\Response |
|
| 201 | - */ |
|
| 202 | - public function changePassword(Request $request) |
|
| 203 | - { |
|
| 204 | - $this->validate($request, [ |
|
| 205 | - 'old_password' => 'required', |
|
| 206 | - 'password' => 'required|confirmed|min:6', |
|
| 207 | - 'password_confirmation' => 'required', |
|
| 208 | - ]); |
|
| 209 | - |
|
| 210 | - return \Response::json($this->repo->changePassword($request->only('old_password', 'password', 'password_confirmation')), 200); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * Confirm email using the confirmation code. |
|
| 215 | - * |
|
| 216 | - * @param \Illuminate\Http\Request $request |
|
| 217 | - * @return \Illuminate\Http\Response |
|
| 218 | - */ |
|
| 219 | - public function confirmEmail(Request $request) |
|
| 220 | - { |
|
| 221 | - $this->validate($request, [ |
|
| 222 | - 'confirmation_code' => 'required|string' |
|
| 223 | - ]); |
|
| 224 | - |
|
| 225 | - return \Response::json($this->repo->confirmEmail($request->only('confirmation_code')), 200); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - /** |
|
| 229 | - * Resend the email confirmation mail. |
|
| 230 | - * |
|
| 231 | - * @param \Illuminate\Http\Request $request |
|
| 232 | - * @return \Illuminate\Http\Response |
|
| 233 | - */ |
|
| 234 | - public function resendEmailConfirmation(Request $request) |
|
| 235 | - { |
|
| 236 | - $this->validate($request, [ |
|
| 237 | - 'email' => 'required|exists:users,email' |
|
| 238 | - ]); |
|
| 239 | - |
|
| 240 | - return \Response::json($this->repo->sendConfirmationEmail($request->get('email')), 200); |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * Refresh the expired login token. |
|
| 245 | - * |
|
| 246 | - * @param \Illuminate\Http\Request $request |
|
| 247 | - * @return \Illuminate\Http\Response |
|
| 248 | - */ |
|
| 249 | - public function refreshtoken(Request $request) |
|
| 250 | - { |
|
| 251 | - $this->validate($request, [ |
|
| 252 | - 'refreshtoken' => 'required', |
|
| 253 | - ]); |
|
| 254 | - |
|
| 255 | - return \Response::json($this->loginProxy->refreshtoken($request->get('refreshtoken')), 200); |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * Paginate all users with in the given group. |
|
| 260 | - * |
|
| 261 | - * @param \Illuminate\Http\Request $request |
|
| 262 | - * @param string $groupName The name of the requested group. |
|
| 263 | - * @param integer $perPage Number of rows per page default 15. |
|
| 264 | - * @param string $sortBy The name of the column to sort by. |
|
| 265 | - * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
| 266 | - * @return \Illuminate\Http\Response |
|
| 267 | - */ |
|
| 268 | - public function group(Request $request, $groupName, $perPage = false, $sortBy = 'created_at', $desc = 1) |
|
| 269 | - { |
|
| 270 | - return \Response::json($this->repo->group($request->all(), $groupName, $this->relations, $perPage, $sortBy, $desc), 200); |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - /** |
|
| 274 | - * Save the given data to the logged in user. |
|
| 275 | - * |
|
| 276 | - * @param \Illuminate\Http\Request $request |
|
| 277 | - * @return \Illuminate\Http\Response |
|
| 278 | - */ |
|
| 279 | - public function saveProfile(Request $request) |
|
| 280 | - { |
|
| 281 | - $this->validate($request, [ |
|
| 282 | - 'profile_picture' => 'nullable|string', |
|
| 283 | - 'name' => 'nullable|string', |
|
| 284 | - 'email' => 'required|email|unique:users,email,'.\Auth::id() |
|
| 285 | - ]); |
|
| 286 | - |
|
| 287 | - return \Response::json($this->repo->saveProfile($request->only('name', 'email', 'profile_picture')), 200); |
|
| 288 | - } |
|
| 11 | + /** |
|
| 12 | + * The name of the model that is used by the base api controller |
|
| 13 | + * to preform actions like (add, edit ... etc). |
|
| 14 | + * @var string |
|
| 15 | + */ |
|
| 16 | + protected $model = 'users'; |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * List of all route actions that the base api controller |
|
| 20 | + * will skip permissions check for them. |
|
| 21 | + * @var array |
|
| 22 | + */ |
|
| 23 | + protected $skipPermissionCheck = ['account', 'logout', 'changePassword', 'saveProfile', 'account']; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * List of all route actions that the base api controller |
|
| 27 | + * will skip login check for them. |
|
| 28 | + * @var array |
|
| 29 | + */ |
|
| 30 | + protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendreset', 'resetpassword', 'refreshtoken', 'confirmEmail', 'resendEmailConfirmation']; |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * The validations rules used by the base api controller |
|
| 34 | + * to check before add. |
|
| 35 | + * @var array |
|
| 36 | + */ |
|
| 37 | + protected $validationRules = [ |
|
| 38 | + 'name' => 'nullable|string', |
|
| 39 | + 'email' => 'required|email|unique:users,email,{id}', |
|
| 40 | + 'password' => 'nullable|min:6' |
|
| 41 | + ]; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * The loginProxy implementation. |
|
| 45 | + * |
|
| 46 | + * @var \App\Modules\Acl\Proxy\LoginProxy |
|
| 47 | + */ |
|
| 48 | + protected $loginProxy; |
|
| 49 | + |
|
| 50 | + public function __construct(LoginProxy $loginProxy) |
|
| 51 | + { |
|
| 52 | + $this->loginProxy = $loginProxy; |
|
| 53 | + parent::__construct(); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * Return the logged in user account. |
|
| 58 | + * |
|
| 59 | + * @return \Illuminate\Http\Response |
|
| 60 | + */ |
|
| 61 | + public function account() |
|
| 62 | + { |
|
| 63 | + return \Response::json($this->repo->account($this->relations), 200); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * Block the user. |
|
| 68 | + * |
|
| 69 | + * @param integer $id Id of the user. |
|
| 70 | + * @return \Illuminate\Http\Response |
|
| 71 | + */ |
|
| 72 | + public function block($id) |
|
| 73 | + { |
|
| 74 | + return \Response::json($this->repo->block($id), 200); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Unblock the user. |
|
| 79 | + * |
|
| 80 | + * @param integer $id Id of the user. |
|
| 81 | + * @return \Illuminate\Http\Response |
|
| 82 | + */ |
|
| 83 | + public function unblock($id) |
|
| 84 | + { |
|
| 85 | + return \Response::json($this->repo->unblock($id), 200); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Logout the user. |
|
| 90 | + * |
|
| 91 | + * @return \Illuminate\Http\Response |
|
| 92 | + */ |
|
| 93 | + public function logout() |
|
| 94 | + { |
|
| 95 | + return \Response::json($this->loginProxy->logout(), 200); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * Handle a registration request. |
|
| 100 | + * |
|
| 101 | + * @param \Illuminate\Http\Request $request |
|
| 102 | + * @return \Illuminate\Http\Response |
|
| 103 | + */ |
|
| 104 | + public function register(Request $request) |
|
| 105 | + { |
|
| 106 | + $this->validate($request, [ |
|
| 107 | + 'name' => 'nullable|string', |
|
| 108 | + 'email' => 'required|email|unique:users,email,{id}', |
|
| 109 | + 'password' => 'required|min:6' |
|
| 110 | + ]); |
|
| 111 | + |
|
| 112 | + return \Response::json($this->repo->register($request->only('name', 'email', 'password')), 200); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + /** |
|
| 116 | + * Handle a login request to the application. |
|
| 117 | + * |
|
| 118 | + * @param \Illuminate\Http\Request $request |
|
| 119 | + * @return \Illuminate\Http\Response |
|
| 120 | + */ |
|
| 121 | + public function login(Request $request) |
|
| 122 | + { |
|
| 123 | + $this->validate($request, [ |
|
| 124 | + 'email' => 'required|email', |
|
| 125 | + 'password' => 'required|min:6', |
|
| 126 | + 'admin' => 'nullable|boolean' |
|
| 127 | + ]); |
|
| 128 | + |
|
| 129 | + return \Response::json($this->loginProxy->login($request->only('email', 'password'), $request->get('admin')), 200); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * Handle a social login request of the none admin to the application. |
|
| 134 | + * |
|
| 135 | + * @param \Illuminate\Http\Request $request |
|
| 136 | + * @return \Illuminate\Http\Response |
|
| 137 | + */ |
|
| 138 | + public function loginSocial(Request $request) |
|
| 139 | + { |
|
| 140 | + $this->validate($request, [ |
|
| 141 | + 'auth_code' => 'required_without:access_token', |
|
| 142 | + 'access_token' => 'required_without:auth_code', |
|
| 143 | + 'type' => 'required|in:facebook,google' |
|
| 144 | + ]); |
|
| 145 | + |
|
| 146 | + return \Response::json($this->repo->loginSocial($request->get('auth_code'), $request->get('access_token'), $request->get('type')), 200); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * Assign the given groups to the given user. |
|
| 151 | + * |
|
| 152 | + * @param \Illuminate\Http\Request $request |
|
| 153 | + * @return \Illuminate\Http\Response |
|
| 154 | + */ |
|
| 155 | + public function assigngroups(Request $request) |
|
| 156 | + { |
|
| 157 | + $this->validate($request, [ |
|
| 158 | + 'group_ids' => 'required|exists:groups,id', |
|
| 159 | + 'user_id' => 'required|exists:users,id' |
|
| 160 | + ]); |
|
| 161 | + |
|
| 162 | + return \Response::json($this->repo->assignGroups($request->get('user_id'), $request->get('group_ids')), 200); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * Send a reset link to the given user. |
|
| 167 | + * |
|
| 168 | + * @param \Illuminate\Http\Request $request |
|
| 169 | + * @return \Illuminate\Http\Response |
|
| 170 | + */ |
|
| 171 | + public function sendreset(Request $request) |
|
| 172 | + { |
|
| 173 | + $this->validate($request, ['email' => 'required|email']); |
|
| 174 | + |
|
| 175 | + return \Response::json($this->repo->sendReset($request->get('email')), 200); |
|
| 176 | + } |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * Reset the given user's password. |
|
| 180 | + * |
|
| 181 | + * @param \Illuminate\Http\Request $request |
|
| 182 | + * @return \Illuminate\Http\Response |
|
| 183 | + */ |
|
| 184 | + public function resetpassword(Request $request) |
|
| 185 | + { |
|
| 186 | + $this->validate($request, [ |
|
| 187 | + 'token' => 'required', |
|
| 188 | + 'email' => 'required|email', |
|
| 189 | + 'password' => 'required|confirmed|min:6', |
|
| 190 | + 'password_confirmation' => 'required', |
|
| 191 | + ]); |
|
| 192 | + |
|
| 193 | + return \Response::json($this->repo->resetPassword($request->only('email', 'password', 'password_confirmation', 'token')), 200); |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * Change the logged in user password. |
|
| 198 | + * |
|
| 199 | + * @param \Illuminate\Http\Request $request |
|
| 200 | + * @return \Illuminate\Http\Response |
|
| 201 | + */ |
|
| 202 | + public function changePassword(Request $request) |
|
| 203 | + { |
|
| 204 | + $this->validate($request, [ |
|
| 205 | + 'old_password' => 'required', |
|
| 206 | + 'password' => 'required|confirmed|min:6', |
|
| 207 | + 'password_confirmation' => 'required', |
|
| 208 | + ]); |
|
| 209 | + |
|
| 210 | + return \Response::json($this->repo->changePassword($request->only('old_password', 'password', 'password_confirmation')), 200); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * Confirm email using the confirmation code. |
|
| 215 | + * |
|
| 216 | + * @param \Illuminate\Http\Request $request |
|
| 217 | + * @return \Illuminate\Http\Response |
|
| 218 | + */ |
|
| 219 | + public function confirmEmail(Request $request) |
|
| 220 | + { |
|
| 221 | + $this->validate($request, [ |
|
| 222 | + 'confirmation_code' => 'required|string' |
|
| 223 | + ]); |
|
| 224 | + |
|
| 225 | + return \Response::json($this->repo->confirmEmail($request->only('confirmation_code')), 200); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + /** |
|
| 229 | + * Resend the email confirmation mail. |
|
| 230 | + * |
|
| 231 | + * @param \Illuminate\Http\Request $request |
|
| 232 | + * @return \Illuminate\Http\Response |
|
| 233 | + */ |
|
| 234 | + public function resendEmailConfirmation(Request $request) |
|
| 235 | + { |
|
| 236 | + $this->validate($request, [ |
|
| 237 | + 'email' => 'required|exists:users,email' |
|
| 238 | + ]); |
|
| 239 | + |
|
| 240 | + return \Response::json($this->repo->sendConfirmationEmail($request->get('email')), 200); |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * Refresh the expired login token. |
|
| 245 | + * |
|
| 246 | + * @param \Illuminate\Http\Request $request |
|
| 247 | + * @return \Illuminate\Http\Response |
|
| 248 | + */ |
|
| 249 | + public function refreshtoken(Request $request) |
|
| 250 | + { |
|
| 251 | + $this->validate($request, [ |
|
| 252 | + 'refreshtoken' => 'required', |
|
| 253 | + ]); |
|
| 254 | + |
|
| 255 | + return \Response::json($this->loginProxy->refreshtoken($request->get('refreshtoken')), 200); |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * Paginate all users with in the given group. |
|
| 260 | + * |
|
| 261 | + * @param \Illuminate\Http\Request $request |
|
| 262 | + * @param string $groupName The name of the requested group. |
|
| 263 | + * @param integer $perPage Number of rows per page default 15. |
|
| 264 | + * @param string $sortBy The name of the column to sort by. |
|
| 265 | + * @param boolean $desc Sort ascending or descinding (1: desc, 0: asc). |
|
| 266 | + * @return \Illuminate\Http\Response |
|
| 267 | + */ |
|
| 268 | + public function group(Request $request, $groupName, $perPage = false, $sortBy = 'created_at', $desc = 1) |
|
| 269 | + { |
|
| 270 | + return \Response::json($this->repo->group($request->all(), $groupName, $this->relations, $perPage, $sortBy, $desc), 200); |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + /** |
|
| 274 | + * Save the given data to the logged in user. |
|
| 275 | + * |
|
| 276 | + * @param \Illuminate\Http\Request $request |
|
| 277 | + * @return \Illuminate\Http\Response |
|
| 278 | + */ |
|
| 279 | + public function saveProfile(Request $request) |
|
| 280 | + { |
|
| 281 | + $this->validate($request, [ |
|
| 282 | + 'profile_picture' => 'nullable|string', |
|
| 283 | + 'name' => 'nullable|string', |
|
| 284 | + 'email' => 'required|email|unique:users,email,'.\Auth::id() |
|
| 285 | + ]); |
|
| 286 | + |
|
| 287 | + return \Response::json($this->repo->saveProfile($request->only('name', 'email', 'profile_picture')), 200); |
|
| 288 | + } |
|
| 289 | 289 | } |
@@ -7,44 +7,44 @@ |
||
| 7 | 7 | |
| 8 | 8 | class OauthClientsController extends BaseApiController |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * The name of the model that is used by the base api controller |
|
| 12 | - * to preform actions like (add, edit ... etc). |
|
| 13 | - * @var string |
|
| 14 | - */ |
|
| 15 | - protected $model = 'oauthClients'; |
|
| 10 | + /** |
|
| 11 | + * The name of the model that is used by the base api controller |
|
| 12 | + * to preform actions like (add, edit ... etc). |
|
| 13 | + * @var string |
|
| 14 | + */ |
|
| 15 | + protected $model = 'oauthClients'; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * The validations rules used by the base api controller |
|
| 19 | - * to check before add. |
|
| 20 | - * @var array |
|
| 21 | - */ |
|
| 22 | - protected $validationRules = [ |
|
| 23 | - 'name' => 'required|max:255', |
|
| 24 | - 'redirect' => 'required|url', |
|
| 25 | - 'user_id' => 'required|exists:users,id', |
|
| 26 | - 'revoked' => 'boolean' |
|
| 27 | - ]; |
|
| 17 | + /** |
|
| 18 | + * The validations rules used by the base api controller |
|
| 19 | + * to check before add. |
|
| 20 | + * @var array |
|
| 21 | + */ |
|
| 22 | + protected $validationRules = [ |
|
| 23 | + 'name' => 'required|max:255', |
|
| 24 | + 'redirect' => 'required|url', |
|
| 25 | + 'user_id' => 'required|exists:users,id', |
|
| 26 | + 'revoked' => 'boolean' |
|
| 27 | + ]; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Revoke the given client. |
|
| 31 | - * |
|
| 32 | - * @param integer $clientId Id of the client |
|
| 33 | - * @return \Illuminate\Http\Response |
|
| 34 | - */ |
|
| 35 | - public function revoke($clientId) |
|
| 36 | - { |
|
| 37 | - return \Response::json($this->repo->revoke($clientId), 200); |
|
| 38 | - } |
|
| 29 | + /** |
|
| 30 | + * Revoke the given client. |
|
| 31 | + * |
|
| 32 | + * @param integer $clientId Id of the client |
|
| 33 | + * @return \Illuminate\Http\Response |
|
| 34 | + */ |
|
| 35 | + public function revoke($clientId) |
|
| 36 | + { |
|
| 37 | + return \Response::json($this->repo->revoke($clientId), 200); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * Un revoke the given client. |
|
| 42 | - * |
|
| 43 | - * @param integer $clientId Id of the client |
|
| 44 | - * @return \Illuminate\Http\Response |
|
| 45 | - */ |
|
| 46 | - public function unRevoke($clientId) |
|
| 47 | - { |
|
| 48 | - return \Response::json($this->repo->unRevoke($clientId), 200); |
|
| 49 | - } |
|
| 40 | + /** |
|
| 41 | + * Un revoke the given client. |
|
| 42 | + * |
|
| 43 | + * @param integer $clientId Id of the client |
|
| 44 | + * @return \Illuminate\Http\Response |
|
| 45 | + */ |
|
| 46 | + public function unRevoke($clientId) |
|
| 47 | + { |
|
| 48 | + return \Response::json($this->repo->unRevoke($clientId), 200); |
|
| 49 | + } |
|
| 50 | 50 | } |
@@ -7,35 +7,35 @@ |
||
| 7 | 7 | |
| 8 | 8 | class GroupsController extends BaseApiController |
| 9 | 9 | { |
| 10 | - /** |
|
| 11 | - * The name of the model that is used by the base api controller |
|
| 12 | - * to preform actions like (add, edit ... etc). |
|
| 13 | - * @var string |
|
| 14 | - */ |
|
| 15 | - protected $model = 'groups'; |
|
| 10 | + /** |
|
| 11 | + * The name of the model that is used by the base api controller |
|
| 12 | + * to preform actions like (add, edit ... etc). |
|
| 13 | + * @var string |
|
| 14 | + */ |
|
| 15 | + protected $model = 'groups'; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * The validations rules used by the base api controller |
|
| 19 | - * to check before add. |
|
| 20 | - * @var array |
|
| 21 | - */ |
|
| 22 | - protected $validationRules = [ |
|
| 23 | - 'name' => 'required|string|max:100|unique:groups,name,{id}' |
|
| 24 | - ]; |
|
| 17 | + /** |
|
| 18 | + * The validations rules used by the base api controller |
|
| 19 | + * to check before add. |
|
| 20 | + * @var array |
|
| 21 | + */ |
|
| 22 | + protected $validationRules = [ |
|
| 23 | + 'name' => 'required|string|max:100|unique:groups,name,{id}' |
|
| 24 | + ]; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * Handle an assign permissions to group request. |
|
| 28 | - * |
|
| 29 | - * @param \Illuminate\Http\Request $request |
|
| 30 | - * @return \Illuminate\Http\Response |
|
| 31 | - */ |
|
| 32 | - public function assignpermissions(Request $request) |
|
| 33 | - { |
|
| 34 | - $this->validate($request, [ |
|
| 35 | - 'permission_ids' => 'required|exists:permissions,id', |
|
| 36 | - 'group_id' => 'required|array|exists:groups,id' |
|
| 37 | - ]); |
|
| 26 | + /** |
|
| 27 | + * Handle an assign permissions to group request. |
|
| 28 | + * |
|
| 29 | + * @param \Illuminate\Http\Request $request |
|
| 30 | + * @return \Illuminate\Http\Response |
|
| 31 | + */ |
|
| 32 | + public function assignpermissions(Request $request) |
|
| 33 | + { |
|
| 34 | + $this->validate($request, [ |
|
| 35 | + 'permission_ids' => 'required|exists:permissions,id', |
|
| 36 | + 'group_id' => 'required|array|exists:groups,id' |
|
| 37 | + ]); |
|
| 38 | 38 | |
| 39 | - return \Response::json($this->repo->assignPermissions($request->get('group_id'), $request->get('permission_ids')), 200); |
|
| 40 | - } |
|
| 39 | + return \Response::json($this->repo->assignPermissions($request->get('group_id'), $request->get('permission_ids')), 200); |
|
| 40 | + } |
|
| 41 | 41 | } |
@@ -5,76 +5,76 @@ |
||
| 5 | 5 | |
| 6 | 6 | class LoginProxy |
| 7 | 7 | { |
| 8 | - /** |
|
| 9 | - * Attempt to create an access token using user credentials. |
|
| 10 | - * |
|
| 11 | - * @param array $credentials |
|
| 12 | - * @param boolean $adminLogin |
|
| 13 | - * @return array |
|
| 14 | - */ |
|
| 15 | - public function login($credentials, $adminLogin = false) |
|
| 16 | - { |
|
| 17 | - \Core::users()->login($credentials, $adminLogin); |
|
| 8 | + /** |
|
| 9 | + * Attempt to create an access token using user credentials. |
|
| 10 | + * |
|
| 11 | + * @param array $credentials |
|
| 12 | + * @param boolean $adminLogin |
|
| 13 | + * @return array |
|
| 14 | + */ |
|
| 15 | + public function login($credentials, $adminLogin = false) |
|
| 16 | + { |
|
| 17 | + \Core::users()->login($credentials, $adminLogin); |
|
| 18 | 18 | |
| 19 | - return $this->proxy('password', [ |
|
| 20 | - 'username' => $credentials['email'], |
|
| 21 | - 'password' => $credentials['password'] |
|
| 22 | - ]); |
|
| 23 | - } |
|
| 19 | + return $this->proxy('password', [ |
|
| 20 | + 'username' => $credentials['email'], |
|
| 21 | + 'password' => $credentials['password'] |
|
| 22 | + ]); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Attempt to refresh the access token useing 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 useing 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('skeleton.passport_client_id'), |
|
| 48 | - 'client_secret' => config('skeleton.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('skeleton.passport_client_id'), |
|
| 48 | + 'client_secret' => config('skeleton.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 | - \ErrorHandler::invalidRefreshToken(); |
|
| 57 | - } |
|
| 54 | + if (! $response->isSuccessful()) { |
|
| 55 | + if ($grantType == 'refresh_token') { |
|
| 56 | + \ErrorHandler::invalidRefreshToken(); |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - \ErrorHandler::loginFailed(); |
|
| 60 | - } |
|
| 59 | + \ErrorHandler::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 | |
| 71 | - /** |
|
| 72 | - * Logs out the user. We revoke access token and refresh token. |
|
| 73 | - * |
|
| 74 | - * @return void |
|
| 75 | - */ |
|
| 76 | - public function logout() |
|
| 77 | - { |
|
| 78 | - \Core::users()->revokeAccessToken(\Auth::user()->token()); |
|
| 79 | - } |
|
| 71 | + /** |
|
| 72 | + * Logs out the user. We revoke access token and refresh token. |
|
| 73 | + * |
|
| 74 | + * @return void |
|
| 75 | + */ |
|
| 76 | + public function logout() |
|
| 77 | + { |
|
| 78 | + \Core::users()->revokeAccessToken(\Auth::user()->token()); |
|
| 79 | + } |
|
| 80 | 80 | } |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | |
| 52 | 52 | $response = \ApiConsumer::post('/oauth/token', $data); |
| 53 | 53 | |
| 54 | - if (! $response->isSuccessful()) { |
|
| 54 | + if ( ! $response->isSuccessful()) { |
|
| 55 | 55 | if ($grantType == 'refresh_token') { |
| 56 | 56 | \ErrorHandler::invalidRefreshToken(); |
| 57 | 57 | } |
@@ -13,75 +13,75 @@ |
||
| 13 | 13 | |
| 14 | 14 | Route::group(['prefix' => 'acl'], function () { |
| 15 | 15 | |
| 16 | - Route::group(['prefix' => 'users'], function () { |
|
| 16 | + Route::group(['prefix' => 'users'], function () { |
|
| 17 | 17 | |
| 18 | - Route::get('list/{sortBy?}/{desc?}', 'UsersController@index'); |
|
| 19 | - Route::get('find/{id}', 'UsersController@find'); |
|
| 20 | - Route::get('search/{query?}/{perPage?}/{sortBy?}/{desc?}', 'UsersController@search'); |
|
| 21 | - Route::get('paginate/{perPage?}/{sortBy?}/{desc?}', 'UsersController@paginate'); |
|
| 22 | - Route::get('delete/{id}', 'UsersController@delete'); |
|
| 23 | - Route::get('restore/{id}', 'UsersController@restore'); |
|
| 24 | - Route::get('account', 'UsersController@account'); |
|
| 25 | - Route::get('block/{id}', 'UsersController@block'); |
|
| 26 | - Route::get('unblock/{id}', 'UsersController@unblock'); |
|
| 27 | - Route::get('logout', 'UsersController@logout'); |
|
| 28 | - Route::post('refreshtoken', 'UsersController@refreshtoken'); |
|
| 29 | - Route::post('first', 'UsersController@first'); |
|
| 30 | - Route::post('findby/{sortBy?}/{desc?}', 'UsersController@findby'); |
|
| 31 | - Route::post('paginateby/{perPage?}/{sortBy?}/{desc?}', 'UsersController@paginateby'); |
|
| 32 | - Route::post('save', 'UsersController@save'); |
|
| 33 | - Route::post('profile/save', 'UsersController@saveProfile'); |
|
| 34 | - Route::post('deleted/{perPage?}/{sortBy?}/{desc?}', 'UsersController@deleted'); |
|
| 35 | - Route::post('register', 'UsersController@register'); |
|
| 36 | - Route::post('login', 'UsersController@login'); |
|
| 37 | - Route::post('login/social', 'UsersController@loginSocial'); |
|
| 38 | - Route::post('assigngroups', 'UsersController@assigngroups'); |
|
| 39 | - Route::post('sendreset', 'UsersController@sendreset'); |
|
| 40 | - Route::post('resetpassword', 'UsersController@resetpassword'); |
|
| 41 | - Route::post('changepassword', 'UsersController@changePassword'); |
|
| 42 | - Route::post('confirm/email', 'UsersController@confirmEmail'); |
|
| 43 | - Route::post('resend/email/confirmation', 'UsersController@resendEmailConfirmation'); |
|
| 44 | - Route::post('group/{groupName}/{perPage?}/{sortBy?}/{desc?}', 'UsersController@group'); |
|
| 45 | - }); |
|
| 18 | + Route::get('list/{sortBy?}/{desc?}', 'UsersController@index'); |
|
| 19 | + Route::get('find/{id}', 'UsersController@find'); |
|
| 20 | + Route::get('search/{query?}/{perPage?}/{sortBy?}/{desc?}', 'UsersController@search'); |
|
| 21 | + Route::get('paginate/{perPage?}/{sortBy?}/{desc?}', 'UsersController@paginate'); |
|
| 22 | + Route::get('delete/{id}', 'UsersController@delete'); |
|
| 23 | + Route::get('restore/{id}', 'UsersController@restore'); |
|
| 24 | + Route::get('account', 'UsersController@account'); |
|
| 25 | + Route::get('block/{id}', 'UsersController@block'); |
|
| 26 | + Route::get('unblock/{id}', 'UsersController@unblock'); |
|
| 27 | + Route::get('logout', 'UsersController@logout'); |
|
| 28 | + Route::post('refreshtoken', 'UsersController@refreshtoken'); |
|
| 29 | + Route::post('first', 'UsersController@first'); |
|
| 30 | + Route::post('findby/{sortBy?}/{desc?}', 'UsersController@findby'); |
|
| 31 | + Route::post('paginateby/{perPage?}/{sortBy?}/{desc?}', 'UsersController@paginateby'); |
|
| 32 | + Route::post('save', 'UsersController@save'); |
|
| 33 | + Route::post('profile/save', 'UsersController@saveProfile'); |
|
| 34 | + Route::post('deleted/{perPage?}/{sortBy?}/{desc?}', 'UsersController@deleted'); |
|
| 35 | + Route::post('register', 'UsersController@register'); |
|
| 36 | + Route::post('login', 'UsersController@login'); |
|
| 37 | + Route::post('login/social', 'UsersController@loginSocial'); |
|
| 38 | + Route::post('assigngroups', 'UsersController@assigngroups'); |
|
| 39 | + Route::post('sendreset', 'UsersController@sendreset'); |
|
| 40 | + Route::post('resetpassword', 'UsersController@resetpassword'); |
|
| 41 | + Route::post('changepassword', 'UsersController@changePassword'); |
|
| 42 | + Route::post('confirm/email', 'UsersController@confirmEmail'); |
|
| 43 | + Route::post('resend/email/confirmation', 'UsersController@resendEmailConfirmation'); |
|
| 44 | + Route::post('group/{groupName}/{perPage?}/{sortBy?}/{desc?}', 'UsersController@group'); |
|
| 45 | + }); |
|
| 46 | 46 | |
| 47 | - Route::group(['prefix' => 'groups'], function () { |
|
| 47 | + Route::group(['prefix' => 'groups'], function () { |
|
| 48 | 48 | |
| 49 | - Route::get('list/{sortBy?}/{desc?}', 'GroupsController@index'); |
|
| 50 | - Route::get('find/{id}', 'GroupsController@find'); |
|
| 51 | - Route::get('search/{query?}/{perPage?}/{sortBy?}/{desc?}', 'GroupsController@search'); |
|
| 52 | - Route::get('paginate/{perPage?}/{sortBy?}/{desc?}', 'GroupsController@paginate'); |
|
| 53 | - Route::get('delete/{id}', 'GroupsController@delete'); |
|
| 54 | - Route::get('restore/{id}', 'GroupsController@restore'); |
|
| 55 | - Route::post('first', 'GroupsController@first'); |
|
| 56 | - Route::post('findby/{sortBy?}/{desc?}', 'GroupsController@findby'); |
|
| 57 | - Route::post('paginateby/{perPage?}/{sortBy?}/{desc?}', 'GroupsController@paginateby'); |
|
| 58 | - Route::post('save', 'GroupsController@save'); |
|
| 59 | - Route::post('deleted/{perPage?}/{sortBy?}/{desc?}', 'GroupsController@deleted'); |
|
| 60 | - Route::post('assignpermissions', 'GroupsController@assignpermissions'); |
|
| 61 | - }); |
|
| 49 | + Route::get('list/{sortBy?}/{desc?}', 'GroupsController@index'); |
|
| 50 | + Route::get('find/{id}', 'GroupsController@find'); |
|
| 51 | + Route::get('search/{query?}/{perPage?}/{sortBy?}/{desc?}', 'GroupsController@search'); |
|
| 52 | + Route::get('paginate/{perPage?}/{sortBy?}/{desc?}', 'GroupsController@paginate'); |
|
| 53 | + Route::get('delete/{id}', 'GroupsController@delete'); |
|
| 54 | + Route::get('restore/{id}', 'GroupsController@restore'); |
|
| 55 | + Route::post('first', 'GroupsController@first'); |
|
| 56 | + Route::post('findby/{sortBy?}/{desc?}', 'GroupsController@findby'); |
|
| 57 | + Route::post('paginateby/{perPage?}/{sortBy?}/{desc?}', 'GroupsController@paginateby'); |
|
| 58 | + Route::post('save', 'GroupsController@save'); |
|
| 59 | + Route::post('deleted/{perPage?}/{sortBy?}/{desc?}', 'GroupsController@deleted'); |
|
| 60 | + Route::post('assignpermissions', 'GroupsController@assignpermissions'); |
|
| 61 | + }); |
|
| 62 | 62 | |
| 63 | - Route::group(['prefix' => 'permissions'], function () { |
|
| 63 | + Route::group(['prefix' => 'permissions'], function () { |
|
| 64 | 64 | |
| 65 | - Route::get('list/{sortBy?}/{desc?}', 'PermissionsController@index'); |
|
| 66 | - Route::get('find/{id}', 'PermissionsController@find'); |
|
| 67 | - Route::get('search/{query?}/{perPage?}/{sortBy?}/{desc?}', 'PermissionsController@search'); |
|
| 68 | - Route::get('paginate/{perPage?}/{sortBy?}/{desc?}', 'PermissionsController@paginate'); |
|
| 69 | - Route::post('first', 'PermissionsController@first'); |
|
| 70 | - Route::post('findby/{sortBy?}/{desc?}', 'PermissionsController@findby'); |
|
| 71 | - Route::post('paginateby/{perPage?}/{sortBy?}/{desc?}', 'PermissionsController@paginateby'); |
|
| 72 | - }); |
|
| 65 | + Route::get('list/{sortBy?}/{desc?}', 'PermissionsController@index'); |
|
| 66 | + Route::get('find/{id}', 'PermissionsController@find'); |
|
| 67 | + Route::get('search/{query?}/{perPage?}/{sortBy?}/{desc?}', 'PermissionsController@search'); |
|
| 68 | + Route::get('paginate/{perPage?}/{sortBy?}/{desc?}', 'PermissionsController@paginate'); |
|
| 69 | + Route::post('first', 'PermissionsController@first'); |
|
| 70 | + Route::post('findby/{sortBy?}/{desc?}', 'PermissionsController@findby'); |
|
| 71 | + Route::post('paginateby/{perPage?}/{sortBy?}/{desc?}', 'PermissionsController@paginateby'); |
|
| 72 | + }); |
|
| 73 | 73 | |
| 74 | - Route::group(['prefix' => 'oauth/clients'], function () { |
|
| 74 | + Route::group(['prefix' => 'oauth/clients'], function () { |
|
| 75 | 75 | |
| 76 | - Route::get('list/{sortBy?}/{desc?}', 'OauthClientsController@index'); |
|
| 77 | - Route::get('find/{id}', 'OauthClientsController@find'); |
|
| 78 | - Route::get('search/{query?}/{perPage?}/{sortBy?}/{desc?}', 'OauthClientsController@search'); |
|
| 79 | - Route::get('paginate/{perPage?}/{sortBy?}/{desc?}', 'OauthClientsController@paginate'); |
|
| 80 | - Route::get('revoke/{id}', 'OauthClientsController@revoke'); |
|
| 81 | - Route::get('unrevoke/{id}', 'OauthClientsController@unRevoke'); |
|
| 82 | - Route::post('first', 'OauthClientsController@first'); |
|
| 83 | - Route::post('findby/{sortBy?}/{desc?}', 'OauthClientsController@findby'); |
|
| 84 | - Route::post('paginateby/{perPage?}/{sortBy?}/{desc?}', 'OauthClientsController@paginateby'); |
|
| 85 | - Route::post('save', 'OauthClientsController@save'); |
|
| 86 | - }); |
|
| 76 | + Route::get('list/{sortBy?}/{desc?}', 'OauthClientsController@index'); |
|
| 77 | + Route::get('find/{id}', 'OauthClientsController@find'); |
|
| 78 | + Route::get('search/{query?}/{perPage?}/{sortBy?}/{desc?}', 'OauthClientsController@search'); |
|
| 79 | + Route::get('paginate/{perPage?}/{sortBy?}/{desc?}', 'OauthClientsController@paginate'); |
|
| 80 | + Route::get('revoke/{id}', 'OauthClientsController@revoke'); |
|
| 81 | + Route::get('unrevoke/{id}', 'OauthClientsController@unRevoke'); |
|
| 82 | + Route::post('first', 'OauthClientsController@first'); |
|
| 83 | + Route::post('findby/{sortBy?}/{desc?}', 'OauthClientsController@findby'); |
|
| 84 | + Route::post('paginateby/{perPage?}/{sortBy?}/{desc?}', 'OauthClientsController@paginateby'); |
|
| 85 | + Route::post('save', 'OauthClientsController@save'); |
|
| 86 | + }); |
|
| 87 | 87 | }); |
@@ -11,9 +11,9 @@ discard block |
||
| 11 | 11 | | |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -Route::group(['prefix' => 'acl'], function () { |
|
| 14 | +Route::group(['prefix' => 'acl'], function() { |
|
| 15 | 15 | |
| 16 | - Route::group(['prefix' => 'users'], function () { |
|
| 16 | + Route::group(['prefix' => 'users'], function() { |
|
| 17 | 17 | |
| 18 | 18 | Route::get('list/{sortBy?}/{desc?}', 'UsersController@index'); |
| 19 | 19 | Route::get('find/{id}', 'UsersController@find'); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | Route::post('group/{groupName}/{perPage?}/{sortBy?}/{desc?}', 'UsersController@group'); |
| 45 | 45 | }); |
| 46 | 46 | |
| 47 | - Route::group(['prefix' => 'groups'], function () { |
|
| 47 | + Route::group(['prefix' => 'groups'], function() { |
|
| 48 | 48 | |
| 49 | 49 | Route::get('list/{sortBy?}/{desc?}', 'GroupsController@index'); |
| 50 | 50 | Route::get('find/{id}', 'GroupsController@find'); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | Route::post('assignpermissions', 'GroupsController@assignpermissions'); |
| 61 | 61 | }); |
| 62 | 62 | |
| 63 | - Route::group(['prefix' => 'permissions'], function () { |
|
| 63 | + Route::group(['prefix' => 'permissions'], function() { |
|
| 64 | 64 | |
| 65 | 65 | Route::get('list/{sortBy?}/{desc?}', 'PermissionsController@index'); |
| 66 | 66 | Route::get('find/{id}', 'PermissionsController@find'); |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | Route::post('paginateby/{perPage?}/{sortBy?}/{desc?}', 'PermissionsController@paginateby'); |
| 72 | 72 | }); |
| 73 | 73 | |
| 74 | - Route::group(['prefix' => 'oauth/clients'], function () { |
|
| 74 | + Route::group(['prefix' => 'oauth/clients'], function() { |
|
| 75 | 75 | |
| 76 | 76 | Route::get('list/{sortBy?}/{desc?}', 'OauthClientsController@index'); |
| 77 | 77 | Route::get('find/{id}', 'OauthClientsController@find'); |