Completed
Push — master ( 634be5...2c8eb1 )
by Sherif
10:27
created
src/Modules/V1/Acl/Http/Controllers/GroupsController.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -8,35 +8,35 @@
 block discarded – undo
8 8
 
9 9
 class GroupsController 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               = 'groups';
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               = 'groups';
17 17
 
18
-    /**
19
-     * The validations rules used by the base api controller
20
-     * to check before add.
21
-     * @var array
22
-     */
23
-    protected $validationRules  = [
24
-    'name' => 'required|string|max:100|unique:groups,name,{id}'
25
-    ];
18
+	/**
19
+	 * The validations rules used by the base api controller
20
+	 * to check before add.
21
+	 * @var array
22
+	 */
23
+	protected $validationRules  = [
24
+	'name' => 'required|string|max:100|unique:groups,name,{id}'
25
+	];
26 26
 
27
-    /**
28
-     * Handle an assign permissions to group request.
29
-     *
30
-     * @param  \Illuminate\Http\Request  $request
31
-     * @return \Illuminate\Http\Response
32
-     */
33
-    public function assignpermissions(Request $request)
34
-    {
35
-        $this->validate($request, [
36
-            'permission_ids' => 'required|exists:permissions,id', 
37
-            'group_id'       => 'required|array|exists:groups,id'
38
-            ]);
27
+	/**
28
+	 * Handle an assign permissions to group request.
29
+	 *
30
+	 * @param  \Illuminate\Http\Request  $request
31
+	 * @return \Illuminate\Http\Response
32
+	 */
33
+	public function assignpermissions(Request $request)
34
+	{
35
+		$this->validate($request, [
36
+			'permission_ids' => 'required|exists:permissions,id', 
37
+			'group_id'       => 'required|array|exists:groups,id'
38
+			]);
39 39
 
40
-        return \Response::json(\Core::groups()->assignPermissions($request->get('group_id'), $request->get('permission_ids')), 200);
41
-    }
40
+		return \Response::json(\Core::groups()->assignPermissions($request->get('group_id'), $request->get('permission_ids')), 200);
41
+	}
42 42
 }
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Repositories/GroupRepository.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,6 +29,6 @@
 block discarded – undo
29 29
 			$group->permissions()->attach($permission_ids);
30 30
 		});
31 31
 
32
-        return $this->find($group_id);
32
+		return $this->find($group_id);
33 33
 	}
34 34
 }
Please login to merge, or discard this patch.
src/lang/ar/errors.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -2,25 +2,25 @@
 block discarded – undo
2 2
 
3 3
 return [
4 4
     
5
-    /**
6
-     * List of error messages used in core module.
7
-     */
8
-    'unAuthorized'           => 'من فضلك قم بتسجيل الدخول',
9
-    'tokenExpired'           => 'انتهت صلاحية الدخول',
10
-    'noPermissions'          => 'لا توجد صلاحية',
11
-    'loginFailed'            => 'خطأ في البريد لاكتروني او كلمة المرور',
12
-    'noSocialEmail'          => 'لا يمكن الحصول علي تابريد الاكتروني',
13
-    'userAlreadyRegistered'  => 'المستخد مسجل بالفعل.سجل الدخول بالبريد الاكتروني و كلمة السر',
14
-    'connectionError'        => 'خطأ في الاتصال',
15
-    'redisNotRunning'        => 'سيرفير الاشعارات لايعمل',
16
-    'dbQueryError'           => 'خطا في البيانات',
17
-    'cannotCreateSetting'    => 'لا يمكن اضافة اعدادات',
18
-    'cannotUpdateSettingKey' => 'لا يمكن تعديل اعدادات',
19
-    'userIsBlocked'          => 'لقد تم حظرك',
20
-    'invalidResetToken'      => 'رمز تعديل كلمة المرور خطا',
21
-    'invalidResetPassword'   => 'خطا في نعديل كلمة المرور',
22
-    'invalidOldPassword'     => 'كلمة السر القديمه خطا',
23
-    'notFound'               => 'ال :replace المطلوب غير موجود',
24
-    'generalError'           => 'حدث خطا ما',
5
+	/**
6
+	 * List of error messages used in core module.
7
+	 */
8
+	'unAuthorized'           => 'من فضلك قم بتسجيل الدخول',
9
+	'tokenExpired'           => 'انتهت صلاحية الدخول',
10
+	'noPermissions'          => 'لا توجد صلاحية',
11
+	'loginFailed'            => 'خطأ في البريد لاكتروني او كلمة المرور',
12
+	'noSocialEmail'          => 'لا يمكن الحصول علي تابريد الاكتروني',
13
+	'userAlreadyRegistered'  => 'المستخد مسجل بالفعل.سجل الدخول بالبريد الاكتروني و كلمة السر',
14
+	'connectionError'        => 'خطأ في الاتصال',
15
+	'redisNotRunning'        => 'سيرفير الاشعارات لايعمل',
16
+	'dbQueryError'           => 'خطا في البيانات',
17
+	'cannotCreateSetting'    => 'لا يمكن اضافة اعدادات',
18
+	'cannotUpdateSettingKey' => 'لا يمكن تعديل اعدادات',
19
+	'userIsBlocked'          => 'لقد تم حظرك',
20
+	'invalidResetToken'      => 'رمز تعديل كلمة المرور خطا',
21
+	'invalidResetPassword'   => 'خطا في نعديل كلمة المرور',
22
+	'invalidOldPassword'     => 'كلمة السر القديمه خطا',
23
+	'notFound'               => 'ال :replace المطلوب غير موجود',
24
+	'generalError'           => 'حدث خطا ما',
25 25
 
26 26
 ];
27 27
\ No newline at end of file
Please login to merge, or discard this patch.
src/lang/en/errors.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -2,25 +2,25 @@
 block discarded – undo
2 2
 
3 3
 return [
4 4
     
5
-    /**
6
-     * List of error messages used in core module.
7
-     */
8
-    'unAuthorized'           => 'Please login before any action',
9
-    'tokenExpired'           => 'Login token expired',
10
-    'noPermissions'          => 'No permissions',
11
-    'loginFailed'            => 'Wrong mail or password',
12
-    'noSocialEmail'          => 'Couldn\'t retrieve email',
13
-    'userAlreadyRegistered'  => 'User already registered. Please login using email and password',
14
-    'connectionError'        => 'Connection error',
15
-    'redisNotRunning'        => 'Your redis notification server is\'t running',
16
-    'dbQueryError'           => 'Please check the given inputes',
17
-    'cannotCreateSetting'    => 'Can\'t create setting',
18
-    'cannotUpdateSettingKey' => 'Can\'t update setting key',
19
-    'userIsBlocked'          => 'You have been blocked',
20
-    'invalidResetToken'      => 'Reset password token is invalid',
21
-    'invalidResetPassword'   => 'Reset password is invalid',
22
-    'invalidOldPassword'     => 'Old password is invalid',
23
-    'notFound'               => 'The requested :replace not found',
24
-    'generalError'           => 'Something went wrong',
5
+	/**
6
+	 * List of error messages used in core module.
7
+	 */
8
+	'unAuthorized'           => 'Please login before any action',
9
+	'tokenExpired'           => 'Login token expired',
10
+	'noPermissions'          => 'No permissions',
11
+	'loginFailed'            => 'Wrong mail or password',
12
+	'noSocialEmail'          => 'Couldn\'t retrieve email',
13
+	'userAlreadyRegistered'  => 'User already registered. Please login using email and password',
14
+	'connectionError'        => 'Connection error',
15
+	'redisNotRunning'        => 'Your redis notification server is\'t running',
16
+	'dbQueryError'           => 'Please check the given inputes',
17
+	'cannotCreateSetting'    => 'Can\'t create setting',
18
+	'cannotUpdateSettingKey' => 'Can\'t update setting key',
19
+	'userIsBlocked'          => 'You have been blocked',
20
+	'invalidResetToken'      => 'Reset password token is invalid',
21
+	'invalidResetPassword'   => 'Reset password is invalid',
22
+	'invalidOldPassword'     => 'Old password is invalid',
23
+	'notFound'               => 'The requested :replace not found',
24
+	'generalError'           => 'Something went wrong',
25 25
 
26 26
 ];
27 27
\ No newline at end of file
Please login to merge, or discard this patch.
Modules/V1/Acl/Database/Migrations/2015_12_20_124154_password_resets.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -5,27 +5,27 @@
 block discarded – undo
5 5
 
6 6
 class PasswordResets extends Migration
7 7
 {
8
-    /**
9
-     * Run the migrations.
10
-     *
11
-     * @return void
12
-     */
13
-    public function up()
14
-    {
15
-        Schema::create('password_resets', function (Blueprint $table) {
16
-            $table->string('email')->index();
17
-            $table->string('token')->index();
18
-            $table->timestamp('created_at');
19
-        });
20
-    }
8
+	/**
9
+	 * Run the migrations.
10
+	 *
11
+	 * @return void
12
+	 */
13
+	public function up()
14
+	{
15
+		Schema::create('password_resets', function (Blueprint $table) {
16
+			$table->string('email')->index();
17
+			$table->string('token')->index();
18
+			$table->timestamp('created_at');
19
+		});
20
+	}
21 21
 
22
-    /**
23
-     * Reverse the migrations.
24
-     *
25
-     * @return void
26
-     */
27
-    public function down()
28
-    {
29
-        Schema::dropIfExists('password_resets');
30
-    }
22
+	/**
23
+	 * Reverse the migrations.
24
+	 *
25
+	 * @return void
26
+	 */
27
+	public function down()
28
+	{
29
+		Schema::dropIfExists('password_resets');
30
+	}
31 31
 }
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Database/Migrations/2015_12_20_124153_users.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -13,16 +13,16 @@
 block discarded – undo
13 13
 	public function up()
14 14
 	{
15 15
 		Schema::create('users', function (Blueprint $table) {
16
-            $table->increments('id');
17
-            $table->string('name', 100)->nullable();
18
-            $table->string('email')->unique();
19
-            $table->string('password', 60)->nullable();
20
-            $table->boolean('blocked')->default(0);
16
+			$table->increments('id');
17
+			$table->string('name', 100)->nullable();
18
+			$table->string('email')->unique();
19
+			$table->string('password', 60)->nullable();
20
+			$table->boolean('blocked')->default(0);
21 21
 			$table->date('last_change_password')->nullable();
22
-            $table->softDeletes();
23
-            $table->rememberToken();
24
-            $table->timestamps();
25
-        });
22
+			$table->softDeletes();
23
+			$table->rememberToken();
24
+			$table->timestamps();
25
+		});
26 26
 	}
27 27
 
28 28
 	/**
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Repositories/UserRepository.php 1 patch
Indentation   +332 added lines, -332 removed lines patch added patch discarded remove patch
@@ -4,340 +4,340 @@
 block discarded – undo
4 4
 
5 5
 class UserRepository extends AbstractRepository
6 6
 {
7
-    /**
8
-     * Return the model full namespace.
9
-     * 
10
-     * @return string
11
-     */
12
-    protected function getModel()
13
-    {
14
-        return 'App\Modules\V1\Acl\AclUser';
15
-    }
16
-
17
-    /**
18
-     * Return the logged in user account.
19
-     *
20
-     * @param  array   $relations
21
-     * @return boolean
22
-     */
23
-    public function account($relations = [])
24
-    {
25
-        $permissions = [];
26
-        $user        = \Core::users()->find(\JWTAuth::parseToken()->authenticate()->id, $relations);
27
-        foreach ($user->groups()->get() as $group)
28
-        {
29
-            $group->permissions->each(function ($permission) use (&$permissions){
30
-                $permissions[$permission->model][$permission->id] = $permission->name;
31
-            });
32
-        }
33
-        $user->permissions = $permissions;
34
-
35
-       return $user;
36
-    }
37
-
38
-    /**
39
-     * Check if the logged in user or the given user 
40
-     * has the given permissions on the given model.
41
-     * 
42
-     * @param  string  $nameOfPermission
43
-     * @param  string  $model            
44
-     * @param  boolean $user
45
-     * @return boolean
46
-     */
47
-    public function can($nameOfPermission, $model, $user = false )
48
-    {      
49
-        $user        = $user ?: \JWTAuth::parseToken()->authenticate();
50
-        $permissions = [];
51
-
52
-        if ( ! $user = $this->find($user->id, ['groups.permissions'])) 
53
-        {
54
-            \ErrorHandler::tokenExpired();
55
-        }
56
-
57
-        $user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){
58
-            $permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); 
59
-        });
7
+	/**
8
+	 * Return the model full namespace.
9
+	 * 
10
+	 * @return string
11
+	 */
12
+	protected function getModel()
13
+	{
14
+		return 'App\Modules\V1\Acl\AclUser';
15
+	}
16
+
17
+	/**
18
+	 * Return the logged in user account.
19
+	 *
20
+	 * @param  array   $relations
21
+	 * @return boolean
22
+	 */
23
+	public function account($relations = [])
24
+	{
25
+		$permissions = [];
26
+		$user        = \Core::users()->find(\JWTAuth::parseToken()->authenticate()->id, $relations);
27
+		foreach ($user->groups()->get() as $group)
28
+		{
29
+			$group->permissions->each(function ($permission) use (&$permissions){
30
+				$permissions[$permission->model][$permission->id] = $permission->name;
31
+			});
32
+		}
33
+		$user->permissions = $permissions;
34
+
35
+	   return $user;
36
+	}
37
+
38
+	/**
39
+	 * Check if the logged in user or the given user 
40
+	 * has the given permissions on the given model.
41
+	 * 
42
+	 * @param  string  $nameOfPermission
43
+	 * @param  string  $model            
44
+	 * @param  boolean $user
45
+	 * @return boolean
46
+	 */
47
+	public function can($nameOfPermission, $model, $user = false )
48
+	{      
49
+		$user        = $user ?: \JWTAuth::parseToken()->authenticate();
50
+		$permissions = [];
51
+
52
+		if ( ! $user = $this->find($user->id, ['groups.permissions'])) 
53
+		{
54
+			\ErrorHandler::tokenExpired();
55
+		}
56
+
57
+		$user->groups->pluck('permissions')->each(function ($permission) use (&$permissions, $model){
58
+			$permissions = array_merge($permissions, $permission->where('model', $model)->pluck('name')->toArray()); 
59
+		});
60 60
         
61
-        return in_array($nameOfPermission, $permissions);
62
-    }
63
-
64
-    /**
65
-     * Check if the logged in user has the given group.
66
-     * 
67
-     * @param  string  $groupName
68
-     * @return boolean
69
-     */
70
-    public function hasGroup($groupName)
71
-    {
72
-        $groups = $this->find(\JWTAuth::parseToken()->authenticate()->id)->groups;
73
-        return $groups->pluck('name')->search($groupName, true) === false ? false : true;
74
-    }
75
-
76
-    /**
77
-     * Assign the given group ids to the given user.
78
-     * 
79
-     * @param  integer $user_id    
80
-     * @param  array   $group_ids
81
-     * @return object
82
-     */
83
-    public function assignGroups($user_id, $group_ids)
84
-    {
85
-        \DB::transaction(function () use ($user_id, $group_ids) {
86
-            $user = $this->find($user_id);
87
-            $user->groups()->detach();
88
-            $user->groups()->attach($group_ids);
89
-        });
90
-
91
-        return $this->find($user_id);
92
-    }
93
-
94
-    /**
95
-     * Handle a login request to the application.
96
-     * 
97
-     * @param  array   $credentials    
98
-     * @param  boolean $adminLogin
99
-     * @return array
100
-     */
101
-    public function login($credentials, $adminLogin = false)
102
-    {
103
-        if ( ! $user = $this->first(['email' => $credentials['email']])) 
104
-        {
105
-            \ErrorHandler::loginFailed();
106
-        }
107
-        else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) 
108
-        {
109
-            \ErrorHandler::loginFailed();
110
-        }
111
-        else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) 
112
-        {
113
-            \ErrorHandler::loginFailed();
114
-        }
115
-        else if ($user->blocked)
116
-        {
117
-            \ErrorHandler::userIsBlocked();
118
-        }
119
-        else if ($token = \JWTAuth::attempt($credentials))
120
-        {
121
-            return ['token' => $token];
122
-        }
123
-        else
124
-        {
125
-            \ErrorHandler::loginFailed();
126
-        }
127
-    }
128
-
129
-    /**
130
-     * Handle a social login request of the none admin to the application.
131
-     * 
132
-     * @param  array   $credentials
133
-     * @return array
134
-     */
135
-    public function loginSocial($credentials)
136
-    {
137
-        $access_token = $credentials['auth_code'] ? \Socialite::driver($credentials['type'])->getAccessToken($credentials['auth_code']) : $credentials['access_token'];   
138
-        $user         = \Socialite::driver($credentials['type'])->userFromToken($access_token);
139
-
140
-        if ( ! $user->email)
141
-        {
142
-            \ErrorHandler::noSocialEmail();
143
-        }
144
-
145
-        if ( ! $registeredUser = $this->model->where('email', $user->email)->first()) 
146
-        {
147
-            $data = ['email' => $user->email, 'password' => ''];
148
-            return $this->register($data);
149
-        }
150
-        else
151
-        {
152
-            if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => '']))
153
-            {
154
-                \ErrorHandler::userAlreadyRegistered();
155
-            }
156
-            return $this->login(['email' => $registeredUser->email, 'password' => ''], false);
157
-        }
158
-    }
61
+		return in_array($nameOfPermission, $permissions);
62
+	}
63
+
64
+	/**
65
+	 * Check if the logged in user has the given group.
66
+	 * 
67
+	 * @param  string  $groupName
68
+	 * @return boolean
69
+	 */
70
+	public function hasGroup($groupName)
71
+	{
72
+		$groups = $this->find(\JWTAuth::parseToken()->authenticate()->id)->groups;
73
+		return $groups->pluck('name')->search($groupName, true) === false ? false : true;
74
+	}
75
+
76
+	/**
77
+	 * Assign the given group ids to the given user.
78
+	 * 
79
+	 * @param  integer $user_id    
80
+	 * @param  array   $group_ids
81
+	 * @return object
82
+	 */
83
+	public function assignGroups($user_id, $group_ids)
84
+	{
85
+		\DB::transaction(function () use ($user_id, $group_ids) {
86
+			$user = $this->find($user_id);
87
+			$user->groups()->detach();
88
+			$user->groups()->attach($group_ids);
89
+		});
90
+
91
+		return $this->find($user_id);
92
+	}
93
+
94
+	/**
95
+	 * Handle a login request to the application.
96
+	 * 
97
+	 * @param  array   $credentials    
98
+	 * @param  boolean $adminLogin
99
+	 * @return array
100
+	 */
101
+	public function login($credentials, $adminLogin = false)
102
+	{
103
+		if ( ! $user = $this->first(['email' => $credentials['email']])) 
104
+		{
105
+			\ErrorHandler::loginFailed();
106
+		}
107
+		else if ($adminLogin && $user->groups->pluck('name')->search('Admin', true) === false) 
108
+		{
109
+			\ErrorHandler::loginFailed();
110
+		}
111
+		else if ( ! $adminLogin && $user->groups->pluck('name')->search('Admin', true) !== false) 
112
+		{
113
+			\ErrorHandler::loginFailed();
114
+		}
115
+		else if ($user->blocked)
116
+		{
117
+			\ErrorHandler::userIsBlocked();
118
+		}
119
+		else if ($token = \JWTAuth::attempt($credentials))
120
+		{
121
+			return ['token' => $token];
122
+		}
123
+		else
124
+		{
125
+			\ErrorHandler::loginFailed();
126
+		}
127
+	}
128
+
129
+	/**
130
+	 * Handle a social login request of the none admin to the application.
131
+	 * 
132
+	 * @param  array   $credentials
133
+	 * @return array
134
+	 */
135
+	public function loginSocial($credentials)
136
+	{
137
+		$access_token = $credentials['auth_code'] ? \Socialite::driver($credentials['type'])->getAccessToken($credentials['auth_code']) : $credentials['access_token'];   
138
+		$user         = \Socialite::driver($credentials['type'])->userFromToken($access_token);
139
+
140
+		if ( ! $user->email)
141
+		{
142
+			\ErrorHandler::noSocialEmail();
143
+		}
144
+
145
+		if ( ! $registeredUser = $this->model->where('email', $user->email)->first()) 
146
+		{
147
+			$data = ['email' => $user->email, 'password' => ''];
148
+			return $this->register($data);
149
+		}
150
+		else
151
+		{
152
+			if ( ! \Auth::attempt(['email' => $registeredUser->email, 'password' => '']))
153
+			{
154
+				\ErrorHandler::userAlreadyRegistered();
155
+			}
156
+			return $this->login(['email' => $registeredUser->email, 'password' => ''], false);
157
+		}
158
+	}
159 159
     
160
-    /**
161
-     * Handle a registration request.
162
-     * 
163
-     * @param  array $credentials
164
-     * @return array
165
-     */
166
-    public function register($credentials)
167
-    {
168
-        return ['token' => \JWTAuth::fromUser($this->model->create($credentials))];
169
-    }
170
-
171
-    /**
172
-     * Logout the user.
173
-     * 
174
-     * @return boolean
175
-     */
176
-    public function logout()
177
-    {
178
-        return \JWTAuth::invalidate(\JWTAuth::getToken());
179
-    }
180
-
181
-    /**
182
-     * Block the user.
183
-     *
184
-     * @param  integer $user_id
185
-     * @return object
186
-     */
187
-    public function block($user_id)
188
-    {
189
-        if ( ! $user = $this->find($user_id)) 
190
-        {
191
-            \ErrorHandler::notFound('user');
192
-        }
193
-        if ( ! $this->hasGroup('Admin'))
194
-        {
195
-            \ErrorHandler::noPermissions();
196
-        }
197
-        else if (\JWTAuth::parseToken()->authenticate()->id == $user_id)
198
-        {
199
-            \ErrorHandler::noPermissions();
200
-        }
201
-        else if ($user->groups->pluck('name')->search('Admin', true) !== false) 
202
-        {
203
-            \ErrorHandler::noPermissions();
204
-        }
205
-
206
-        $user->blocked = 1;
207
-        $user->save();
160
+	/**
161
+	 * Handle a registration request.
162
+	 * 
163
+	 * @param  array $credentials
164
+	 * @return array
165
+	 */
166
+	public function register($credentials)
167
+	{
168
+		return ['token' => \JWTAuth::fromUser($this->model->create($credentials))];
169
+	}
170
+
171
+	/**
172
+	 * Logout the user.
173
+	 * 
174
+	 * @return boolean
175
+	 */
176
+	public function logout()
177
+	{
178
+		return \JWTAuth::invalidate(\JWTAuth::getToken());
179
+	}
180
+
181
+	/**
182
+	 * Block the user.
183
+	 *
184
+	 * @param  integer $user_id
185
+	 * @return object
186
+	 */
187
+	public function block($user_id)
188
+	{
189
+		if ( ! $user = $this->find($user_id)) 
190
+		{
191
+			\ErrorHandler::notFound('user');
192
+		}
193
+		if ( ! $this->hasGroup('Admin'))
194
+		{
195
+			\ErrorHandler::noPermissions();
196
+		}
197
+		else if (\JWTAuth::parseToken()->authenticate()->id == $user_id)
198
+		{
199
+			\ErrorHandler::noPermissions();
200
+		}
201
+		else if ($user->groups->pluck('name')->search('Admin', true) !== false) 
202
+		{
203
+			\ErrorHandler::noPermissions();
204
+		}
205
+
206
+		$user->blocked = 1;
207
+		$user->save();
208 208
         
209
-        return $user;
210
-    }
211
-
212
-    /**
213
-     * Unblock the user.
214
-     *
215
-     * @param  integer $user_id
216
-     * @return object
217
-     */
218
-    public function unblock($user_id)
219
-    {
220
-        if ( ! $this->hasGroup('Admin'))
221
-        {
222
-            \ErrorHandler::noPermissions();
223
-        }
224
-
225
-        $user          = $this->find($user_id);
226
-        $user->blocked = 0;
227
-        $user->save();
228
-
229
-        return $user;
230
-    }
231
-
232
-    /**
233
-     * Send a reset link to the given user.
234
-     *
235
-     * @param  string  $url
236
-     * @param  string  $email
237
-     * @return void
238
-     */
239
-    public function sendReset($email, $url)
240
-    {
241
-        view()->composer('auth.emails.password', function($view) use ($url) {
242
-            $view->with(['url' => $url]);
243
-        });
244
-
245
-        $response = \Password::sendResetLink($email, function (\Illuminate\Mail\Message $message) {
246
-            $message->subject('Your Password Reset Link');
247
-        });
248
-
249
-        switch ($response) 
250
-        {
251
-            case \Password::INVALID_USER:
252
-                \ErrorHandler::notFound('email');
253
-        }
254
-    }
255
-
256
-    /**
257
-     * Reset the given user's password.
258
-     *
259
-     * @param  array  $credentials
260
-     * @return array
261
-     */
262
-    public function resetPassword($credentials)
263
-    {
264
-        $token    = false;
265
-        $response = \Password::reset($credentials, function ($user, $password) use (&$token) {
266
-            $user->password = bcrypt($password);
267
-            $user->save();
268
-
269
-            $token = \JWTAuth::fromUser($user);
270
-        });
271
-
272
-        switch ($response) {
273
-            case \Password::PASSWORD_RESET:
274
-                return ['token' => $token];
209
+		return $user;
210
+	}
211
+
212
+	/**
213
+	 * Unblock the user.
214
+	 *
215
+	 * @param  integer $user_id
216
+	 * @return object
217
+	 */
218
+	public function unblock($user_id)
219
+	{
220
+		if ( ! $this->hasGroup('Admin'))
221
+		{
222
+			\ErrorHandler::noPermissions();
223
+		}
224
+
225
+		$user          = $this->find($user_id);
226
+		$user->blocked = 0;
227
+		$user->save();
228
+
229
+		return $user;
230
+	}
231
+
232
+	/**
233
+	 * Send a reset link to the given user.
234
+	 *
235
+	 * @param  string  $url
236
+	 * @param  string  $email
237
+	 * @return void
238
+	 */
239
+	public function sendReset($email, $url)
240
+	{
241
+		view()->composer('auth.emails.password', function($view) use ($url) {
242
+			$view->with(['url' => $url]);
243
+		});
244
+
245
+		$response = \Password::sendResetLink($email, function (\Illuminate\Mail\Message $message) {
246
+			$message->subject('Your Password Reset Link');
247
+		});
248
+
249
+		switch ($response) 
250
+		{
251
+			case \Password::INVALID_USER:
252
+				\ErrorHandler::notFound('email');
253
+		}
254
+	}
255
+
256
+	/**
257
+	 * Reset the given user's password.
258
+	 *
259
+	 * @param  array  $credentials
260
+	 * @return array
261
+	 */
262
+	public function resetPassword($credentials)
263
+	{
264
+		$token    = false;
265
+		$response = \Password::reset($credentials, function ($user, $password) use (&$token) {
266
+			$user->password = bcrypt($password);
267
+			$user->save();
268
+
269
+			$token = \JWTAuth::fromUser($user);
270
+		});
271
+
272
+		switch ($response) {
273
+			case \Password::PASSWORD_RESET:
274
+				return ['token' => $token];
275 275
                 
276
-            case \Password::INVALID_TOKEN:
277
-                \ErrorHandler::invalidResetToken('token');
278
-
279
-            case \Password::INVALID_PASSWORD:
280
-                \ErrorHandler::invalidResetPassword('email');
281
-
282
-            case \Password::INVALID_USER:
283
-                \ErrorHandler::notFound('user');
284
-
285
-            default:
286
-                \ErrorHandler::generalError();
287
-        }
288
-    }
289
-
290
-    /**
291
-     * Change the logged in user password.
292
-     *
293
-     * @param  array  $credentials
294
-     * @return void
295
-     */
296
-    public function changePassword($credentials)
297
-    {
298
-        $user = $this->find(\JWTAuth::parseToken()->authenticate()->id, $relations);
299
-        if ( ! \Hash::check($credentials['old_password'], $user->password)) 
300
-        {
301
-            \ErrorHandler::invalidOldPassword();
302
-        }
303
-
304
-        $user->password = $credentials['password'];
305
-        $user->save();
306
-    }
307
-
308
-    /**
309
-     * Refresh the expired login token.
310
-     *
311
-     * @return array
312
-     */
313
-    public function refreshtoken()
314
-    {
315
-        $token = \JWTAuth::parseToken()->refresh();
316
-
317
-        return ['token' => $token];
318
-    }
319
-
320
-    /**
321
-     * Paginate all users in the given group based on the given conditions.
322
-     * 
323
-     * @param  string  $groupName
324
-     * @param  array   $relations
325
-     * @param  integer $perPage
326
-     * @param  string  $sortBy
327
-     * @param  boolean $desc
328
-     * @return \Illuminate\Http\Response
329
-     */
330
-    public function group($conditions, $groupName, $relations, $perPage, $sortBy, $desc)
331
-    {   
332
-        unset($conditions['page']);
333
-        $conditions = $this->constructConditions($conditions);
334
-        $sort       = $desc ? 'desc' : 'asc';
335
-        $model      = call_user_func_array("{$this->getModel()}::with", array($relations));
336
-
337
-        $model->whereHas('groups', function($q) use ($groupName){
338
-            $q->where('name', $groupName);
339
-        });
340
-
341
-        return $model->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->paginate($perPage);
342
-    }
276
+			case \Password::INVALID_TOKEN:
277
+				\ErrorHandler::invalidResetToken('token');
278
+
279
+			case \Password::INVALID_PASSWORD:
280
+				\ErrorHandler::invalidResetPassword('email');
281
+
282
+			case \Password::INVALID_USER:
283
+				\ErrorHandler::notFound('user');
284
+
285
+			default:
286
+				\ErrorHandler::generalError();
287
+		}
288
+	}
289
+
290
+	/**
291
+	 * Change the logged in user password.
292
+	 *
293
+	 * @param  array  $credentials
294
+	 * @return void
295
+	 */
296
+	public function changePassword($credentials)
297
+	{
298
+		$user = $this->find(\JWTAuth::parseToken()->authenticate()->id, $relations);
299
+		if ( ! \Hash::check($credentials['old_password'], $user->password)) 
300
+		{
301
+			\ErrorHandler::invalidOldPassword();
302
+		}
303
+
304
+		$user->password = $credentials['password'];
305
+		$user->save();
306
+	}
307
+
308
+	/**
309
+	 * Refresh the expired login token.
310
+	 *
311
+	 * @return array
312
+	 */
313
+	public function refreshtoken()
314
+	{
315
+		$token = \JWTAuth::parseToken()->refresh();
316
+
317
+		return ['token' => $token];
318
+	}
319
+
320
+	/**
321
+	 * Paginate all users in the given group based on the given conditions.
322
+	 * 
323
+	 * @param  string  $groupName
324
+	 * @param  array   $relations
325
+	 * @param  integer $perPage
326
+	 * @param  string  $sortBy
327
+	 * @param  boolean $desc
328
+	 * @return \Illuminate\Http\Response
329
+	 */
330
+	public function group($conditions, $groupName, $relations, $perPage, $sortBy, $desc)
331
+	{   
332
+		unset($conditions['page']);
333
+		$conditions = $this->constructConditions($conditions);
334
+		$sort       = $desc ? 'desc' : 'asc';
335
+		$model      = call_user_func_array("{$this->getModel()}::with", array($relations));
336
+
337
+		$model->whereHas('groups', function($q) use ($groupName){
338
+			$q->where('name', $groupName);
339
+		});
340
+
341
+		return $model->whereRaw($conditions['conditionString'], $conditions['conditionValues'])->orderBy($sortBy, $sort)->paginate($perPage);
342
+	}
343 343
 }
Please login to merge, or discard this patch.
src/Modules/V1/Acl/Http/Controllers/UsersController.php 1 patch
Indentation   +215 added lines, -215 removed lines patch added patch discarded remove patch
@@ -7,219 +7,219 @@
 block discarded – undo
7 7
 
8 8
 class UsersController 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               = 'users';
16
-
17
-    /**
18
-     * List of all route actions that the base api controller
19
-     * will skip permissions check for them.
20
-     * @var array
21
-     */
22
-    protected $skipPermissionCheck = ['account', 'logout', 'sendreset'];
23
-
24
-    /**
25
-     * List of all route actions that the base api controller
26
-     * will skip login check for them.
27
-     * @var array
28
-     */
29
-    protected $skipLoginCheck      = ['login', 'loginSocial', 'register', 'sendreset', 'resetpassword', 'refreshtoken'];
30
-
31
-    /**
32
-     * The validations rules used by the base api controller
33
-     * to check before add.
34
-     * @var array
35
-     */
36
-    protected $validationRules     = [
37
-        'user_name'     => 'string|unique:users,user_name,{id}', 
38
-        'email'         => 'required|email|unique:users,email,{id}', 
39
-        'password'      => 'min:6'
40
-    ];
41
-
42
-    /**
43
-     * Return the logged in user account.
44
-     * 
45
-     * @return \Illuminate\Http\Response
46
-     */
47
-    public function account()
48
-    {
49
-        $relations = $this->relations && $this->relations['account'] ? $this->relations['account'] : [];
50
-        return \Response::json(\Core::users()->account($relations), 200);
51
-    }
52
-
53
-    /**
54
-     * Block the user.
55
-     *
56
-     * @param  integer  $id
57
-     * @return \Illuminate\Http\Response
58
-     */
59
-    public function block($id)
60
-    {
61
-        return \Response::json(\Core::users()->block($id), 200);
62
-    }
63
-
64
-    /**
65
-     * Unblock the user.
66
-     *
67
-     * @param  integer  $id
68
-     * @return \Illuminate\Http\Response
69
-     */
70
-    public function unblock($id)
71
-    {
72
-        return \Response::json(\Core::users()->unblock($id), 200);
73
-    }
74
-
75
-    /**
76
-     * Logout the user.
77
-     * 
78
-     * @return \Illuminate\Http\Response
79
-     */
80
-    public function logout()
81
-    {
82
-        return \Response::json(\Core::users()->logout(), 200);
83
-    }
84
-
85
-    /**
86
-     * Handle a registration request.
87
-     *
88
-     * @param  \Illuminate\Http\Request  $request
89
-     * @return \Illuminate\Http\Response
90
-     */
91
-    public function register(Request $request)
92
-    {
93
-        $this->validate($request, [
94
-            'user_name'     => 'string|unique:users,user_name,{id}', 
95
-            'email'         => 'required|email|unique:users,email,{id}', 
96
-            'password'      => 'required|min:6'
97
-            ]);
98
-
99
-        return \Response::json(\Core::users()->register($request->only('email', 'password')), 200);
100
-    }
101
-
102
-    /**
103
-     * Handle a login request of the none admin to the application.
104
-     *
105
-     * @param  \Illuminate\Http\Request  $request
106
-     * @return \Illuminate\Http\Response
107
-     */
108
-    public function login(Request $request)
109
-    {
110
-        $this->validate($request, [
111
-            'email'    => 'required|email', 
112
-            'password' => 'required|min:6',
113
-            'admin'    => 'boolean'
114
-            ]);
115
-
116
-        return \Response::json(\Core::users()->login($request->only('email', 'password'), $request->get('admin')), 200);
117
-    }
118
-
119
-    /**
120
-     * Handle a social login request of the none admin to the application.
121
-     *
122
-     * @param  \Illuminate\Http\Request  $request
123
-     * @return \Illuminate\Http\Response
124
-     */
125
-    public function loginSocial(Request $request)
126
-    {
127
-        $this->validate($request, [
128
-            'auth_code'    => 'required_without:access_token',
129
-            'access_token' => 'required_without:auth_code',
130
-            'type'         => 'required|in:facebook,google'
131
-            ]);
132
-
133
-        return \Response::json(\Core::users()->loginSocial($request->only('auth_code', 'access_token', 'type')), 200);
134
-    }
135
-
136
-    /**
137
-     * Handle an assign groups to user request.
138
-     *
139
-     * @param  \Illuminate\Http\Request  $request
140
-     * @return \Illuminate\Http\Response
141
-     */
142
-    public function assigngroups(Request $request)
143
-    {
144
-        $this->validate($request, [
145
-            'group_ids' => 'required|exists:groups,id', 
146
-            'user_id'   => 'required|exists:users,id'
147
-            ]);
148
-
149
-        return \Response::json(\Core::users()->assignGroups($request->get('user_id'), $request->get('group_ids')), 200);
150
-    }
151
-
152
-    /**
153
-     * Send a reset link to the given user.
154
-     *
155
-     * @param  \Illuminate\Http\Request  $request
156
-     * @return \Illuminate\Http\Response
157
-     */
158
-    public function sendreset(Request $request)
159
-    {
160
-        $this->validate($request, ['email' => 'required|email', 'url' => 'required|url']);
161
-
162
-        return \Response::json(\Core::users()->sendReset($request->only('email'), $request->get('url')), 200);
163
-    }
164
-
165
-    /**
166
-     * Reset the given user's password.
167
-     *
168
-     * @param  \Illuminate\Http\Request  $request
169
-     * @return \Illuminate\Http\Response
170
-     */
171
-    public function resetpassword(Request $request)
172
-    {
173
-        $this->validate($request, [
174
-            'token'                 => 'required',
175
-            'email'                 => 'required|email',
176
-            'password'              => 'required|confirmed|min:6',
177
-            'password_confirmation' => 'required',
178
-        ]);
179
-
180
-        return \Response::json(\Core::users()->resetPassword($request->only('email', 'password', 'password_confirmation', 'token')), 200);
181
-    }
182
-
183
-    /**
184
-     * Change the logged in user password.
185
-     *
186
-     * @param  \Illuminate\Http\Request  $request
187
-     * @return \Illuminate\Http\Response
188
-     */
189
-    public function changePassword(Request $request)
190
-    {
191
-        $this->validate($request, [
192
-            'old_password'          => 'required',
193
-            'password'              => 'required|confirmed|min:6',
194
-            'password_confirmation' => 'required',
195
-        ]);
196
-
197
-        return \Response::json(\Core::users()->changePassword($request->only('old_password', 'password', 'password_confirmation')), 200);
198
-    }
199
-
200
-    /**
201
-     * Refresh the expired login token.
202
-     *
203
-     * @return \Illuminate\Http\Response
204
-     */
205
-    public function refreshtoken()
206
-    {
207
-        return \Response::json(\Core::users()->refreshtoken(), 200);
208
-    }
209
-
210
-    /**
211
-     * Paginate all users with inthe given group.
212
-     * 
213
-     * @param  \Illuminate\Http\Request  $request
214
-     * @param  string $groupName
215
-     * @param  integer $perPage
216
-     * @param  string  $sortBy
217
-     * @param  boolean $desc
218
-     * @return \Illuminate\Http\Response
219
-     */
220
-    public function group(Request $request, $groupName, $perPage = 15, $sortBy = 'created_at', $desc = 1)
221
-    {
222
-        $relations = $this->relations && $this->relations['group'] ? $this->relations['group'] : [];
223
-        return \Response::json(\Core::users()->group($request->all(), $groupName, $relations, $perPage, $sortBy, $desc), 200);
224
-    }
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               = 'users';
16
+
17
+	/**
18
+	 * List of all route actions that the base api controller
19
+	 * will skip permissions check for them.
20
+	 * @var array
21
+	 */
22
+	protected $skipPermissionCheck = ['account', 'logout', 'sendreset'];
23
+
24
+	/**
25
+	 * List of all route actions that the base api controller
26
+	 * will skip login check for them.
27
+	 * @var array
28
+	 */
29
+	protected $skipLoginCheck      = ['login', 'loginSocial', 'register', 'sendreset', 'resetpassword', 'refreshtoken'];
30
+
31
+	/**
32
+	 * The validations rules used by the base api controller
33
+	 * to check before add.
34
+	 * @var array
35
+	 */
36
+	protected $validationRules     = [
37
+		'user_name'     => 'string|unique:users,user_name,{id}', 
38
+		'email'         => 'required|email|unique:users,email,{id}', 
39
+		'password'      => 'min:6'
40
+	];
41
+
42
+	/**
43
+	 * Return the logged in user account.
44
+	 * 
45
+	 * @return \Illuminate\Http\Response
46
+	 */
47
+	public function account()
48
+	{
49
+		$relations = $this->relations && $this->relations['account'] ? $this->relations['account'] : [];
50
+		return \Response::json(\Core::users()->account($relations), 200);
51
+	}
52
+
53
+	/**
54
+	 * Block the user.
55
+	 *
56
+	 * @param  integer  $id
57
+	 * @return \Illuminate\Http\Response
58
+	 */
59
+	public function block($id)
60
+	{
61
+		return \Response::json(\Core::users()->block($id), 200);
62
+	}
63
+
64
+	/**
65
+	 * Unblock the user.
66
+	 *
67
+	 * @param  integer  $id
68
+	 * @return \Illuminate\Http\Response
69
+	 */
70
+	public function unblock($id)
71
+	{
72
+		return \Response::json(\Core::users()->unblock($id), 200);
73
+	}
74
+
75
+	/**
76
+	 * Logout the user.
77
+	 * 
78
+	 * @return \Illuminate\Http\Response
79
+	 */
80
+	public function logout()
81
+	{
82
+		return \Response::json(\Core::users()->logout(), 200);
83
+	}
84
+
85
+	/**
86
+	 * Handle a registration request.
87
+	 *
88
+	 * @param  \Illuminate\Http\Request  $request
89
+	 * @return \Illuminate\Http\Response
90
+	 */
91
+	public function register(Request $request)
92
+	{
93
+		$this->validate($request, [
94
+			'user_name'     => 'string|unique:users,user_name,{id}', 
95
+			'email'         => 'required|email|unique:users,email,{id}', 
96
+			'password'      => 'required|min:6'
97
+			]);
98
+
99
+		return \Response::json(\Core::users()->register($request->only('email', 'password')), 200);
100
+	}
101
+
102
+	/**
103
+	 * Handle a login request of the none admin to the application.
104
+	 *
105
+	 * @param  \Illuminate\Http\Request  $request
106
+	 * @return \Illuminate\Http\Response
107
+	 */
108
+	public function login(Request $request)
109
+	{
110
+		$this->validate($request, [
111
+			'email'    => 'required|email', 
112
+			'password' => 'required|min:6',
113
+			'admin'    => 'boolean'
114
+			]);
115
+
116
+		return \Response::json(\Core::users()->login($request->only('email', 'password'), $request->get('admin')), 200);
117
+	}
118
+
119
+	/**
120
+	 * Handle a social login request of the none admin to the application.
121
+	 *
122
+	 * @param  \Illuminate\Http\Request  $request
123
+	 * @return \Illuminate\Http\Response
124
+	 */
125
+	public function loginSocial(Request $request)
126
+	{
127
+		$this->validate($request, [
128
+			'auth_code'    => 'required_without:access_token',
129
+			'access_token' => 'required_without:auth_code',
130
+			'type'         => 'required|in:facebook,google'
131
+			]);
132
+
133
+		return \Response::json(\Core::users()->loginSocial($request->only('auth_code', 'access_token', 'type')), 200);
134
+	}
135
+
136
+	/**
137
+	 * Handle an assign groups to user request.
138
+	 *
139
+	 * @param  \Illuminate\Http\Request  $request
140
+	 * @return \Illuminate\Http\Response
141
+	 */
142
+	public function assigngroups(Request $request)
143
+	{
144
+		$this->validate($request, [
145
+			'group_ids' => 'required|exists:groups,id', 
146
+			'user_id'   => 'required|exists:users,id'
147
+			]);
148
+
149
+		return \Response::json(\Core::users()->assignGroups($request->get('user_id'), $request->get('group_ids')), 200);
150
+	}
151
+
152
+	/**
153
+	 * Send a reset link to the given user.
154
+	 *
155
+	 * @param  \Illuminate\Http\Request  $request
156
+	 * @return \Illuminate\Http\Response
157
+	 */
158
+	public function sendreset(Request $request)
159
+	{
160
+		$this->validate($request, ['email' => 'required|email', 'url' => 'required|url']);
161
+
162
+		return \Response::json(\Core::users()->sendReset($request->only('email'), $request->get('url')), 200);
163
+	}
164
+
165
+	/**
166
+	 * Reset the given user's password.
167
+	 *
168
+	 * @param  \Illuminate\Http\Request  $request
169
+	 * @return \Illuminate\Http\Response
170
+	 */
171
+	public function resetpassword(Request $request)
172
+	{
173
+		$this->validate($request, [
174
+			'token'                 => 'required',
175
+			'email'                 => 'required|email',
176
+			'password'              => 'required|confirmed|min:6',
177
+			'password_confirmation' => 'required',
178
+		]);
179
+
180
+		return \Response::json(\Core::users()->resetPassword($request->only('email', 'password', 'password_confirmation', 'token')), 200);
181
+	}
182
+
183
+	/**
184
+	 * Change the logged in user password.
185
+	 *
186
+	 * @param  \Illuminate\Http\Request  $request
187
+	 * @return \Illuminate\Http\Response
188
+	 */
189
+	public function changePassword(Request $request)
190
+	{
191
+		$this->validate($request, [
192
+			'old_password'          => 'required',
193
+			'password'              => 'required|confirmed|min:6',
194
+			'password_confirmation' => 'required',
195
+		]);
196
+
197
+		return \Response::json(\Core::users()->changePassword($request->only('old_password', 'password', 'password_confirmation')), 200);
198
+	}
199
+
200
+	/**
201
+	 * Refresh the expired login token.
202
+	 *
203
+	 * @return \Illuminate\Http\Response
204
+	 */
205
+	public function refreshtoken()
206
+	{
207
+		return \Response::json(\Core::users()->refreshtoken(), 200);
208
+	}
209
+
210
+	/**
211
+	 * Paginate all users with inthe given group.
212
+	 * 
213
+	 * @param  \Illuminate\Http\Request  $request
214
+	 * @param  string $groupName
215
+	 * @param  integer $perPage
216
+	 * @param  string  $sortBy
217
+	 * @param  boolean $desc
218
+	 * @return \Illuminate\Http\Response
219
+	 */
220
+	public function group(Request $request, $groupName, $perPage = 15, $sortBy = 'created_at', $desc = 1)
221
+	{
222
+		$relations = $this->relations && $this->relations['group'] ? $this->relations['group'] : [];
223
+		return \Response::json(\Core::users()->group($request->all(), $groupName, $relations, $perPage, $sortBy, $desc), 200);
224
+	}
225 225
 }
Please login to merge, or discard this patch.
src/Modules/V1/Core/Utl/ErrorHandler.php 1 patch
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -2,105 +2,105 @@
 block discarded – undo
2 2
 
3 3
 class ErrorHandler
4 4
 {
5
-    public function unAuthorized()
6
-    {
7
-        $error = ['status' => 401, 'message' => trans('errors.unAuthorized')];
8
-        abort($error['status'], $error['message']);
9
-    }
10
-
11
-    public function tokenExpired()
12
-    {
13
-        $error = ['status' => 403, 'message' => trans('errors.tokenExpired')];
14
-        abort($error['status'], $error['message']);
15
-    }
16
-
17
-     public function noPermissions()
18
-    {
19
-        $error = ['status' => 403, 'message' => trans('errors.noPermissions')];
20
-        abort($error['status'], $error['message']);
21
-    }
22
-
23
-    public function loginFailed()
24
-    {
25
-        $error = ['status' => 400, 'message' => trans('errors.loginFailed')];
26
-        abort($error['status'], $error['message']);
27
-    }
28
-
29
-    public function noSocialEmail()
30
-    {
31
-        $error = ['status' => 400, 'message' => trans('errors.noSocialEmail')];
32
-        abort($error['status'], $error['message']);
33
-    }
34
-
35
-    public function userAlreadyRegistered()
36
-    {
37
-        $error = ['status' => 400, 'message' => trans('errors.userAlreadyRegistered')];
38
-        abort($error['status'], $error['message']);
39
-    }
40
-
41
-    public function connectionError()
42
-    {
43
-        $error = ['status' => 400, 'message' => trans('errors.connectionError')];
44
-        abort($error['status'], $error['message']);
45
-    }
46
-
47
-    public function redisNotRunning()
48
-    {
49
-        $error = ['status' => 400, 'message' => trans('errors.redisNotRunning')];
50
-        abort($error['status'], $error['message']);
51
-    }
52
-
53
-    public function dbQueryError()
54
-    {
55
-        $error = ['status' => 400, 'message' => trans('errors.dbQueryError')];
56
-        abort($error['status'], $error['message']);
57
-    }
58
-
59
-    public function cannotCreateSetting()
60
-    {
61
-        $error = ['status' => 400, 'message' => trans('errors.cannotCreateSetting')];
62
-        abort($error['status'], $error['message']);
63
-    }
64
-
65
-    public function cannotUpdateSettingKey()
66
-    {
67
-        $error = ['status' => 400, 'message' => trans('errors.cannotUpdateSettingKey')];
68
-        abort($error['status'], $error['message']);
69
-    }
70
-
71
-    public function userIsBlocked()
72
-    {
73
-        $error = ['status' => 403, 'message' => trans('errors.userIsBlocked')];
74
-        abort($error['status'], $error['message']);
75
-    }
76
-
77
-    public function invalidResetToken()
78
-    {
79
-        $error = ['status' => 400, 'message' => trans('errors.invalidResetToken')];
80
-        abort($error['status'], $error['message']);
81
-    }
82
-
83
-    public function invalidResetPassword()
84
-    {
85
-        $error = ['status' => 400, 'message' => trans('errors.invalidResetPassword')];
86
-        abort($error['status'], $error['message']);
87
-    }
88
-
89
-    public function invalidOldPassword()
90
-    {
91
-        $error = ['status' => 400, 'message' => trans('errors.invalidOldPassword')];
92
-        abort($error['status'], $error['message']);
93
-    }
94
-
95
-    public function notFound($text)
96
-    {
97
-        $error = ['status' => 404, 'message' => trans('errors.notFound', ['replace' => $text])];
98
-        abort($error['status'], $error['message']);
99
-    }
100
-
101
-    public function generalError()
102
-    {
103
-        $error = ['status' => 404, 'message' => trans('errors.generalError')];
104
-        abort($error['status'], $error['message']);
105
-    }
5
+	public function unAuthorized()
6
+	{
7
+		$error = ['status' => 401, 'message' => trans('errors.unAuthorized')];
8
+		abort($error['status'], $error['message']);
9
+	}
10
+
11
+	public function tokenExpired()
12
+	{
13
+		$error = ['status' => 403, 'message' => trans('errors.tokenExpired')];
14
+		abort($error['status'], $error['message']);
15
+	}
16
+
17
+	 public function noPermissions()
18
+	{
19
+		$error = ['status' => 403, 'message' => trans('errors.noPermissions')];
20
+		abort($error['status'], $error['message']);
21
+	}
22
+
23
+	public function loginFailed()
24
+	{
25
+		$error = ['status' => 400, 'message' => trans('errors.loginFailed')];
26
+		abort($error['status'], $error['message']);
27
+	}
28
+
29
+	public function noSocialEmail()
30
+	{
31
+		$error = ['status' => 400, 'message' => trans('errors.noSocialEmail')];
32
+		abort($error['status'], $error['message']);
33
+	}
34
+
35
+	public function userAlreadyRegistered()
36
+	{
37
+		$error = ['status' => 400, 'message' => trans('errors.userAlreadyRegistered')];
38
+		abort($error['status'], $error['message']);
39
+	}
40
+
41
+	public function connectionError()
42
+	{
43
+		$error = ['status' => 400, 'message' => trans('errors.connectionError')];
44
+		abort($error['status'], $error['message']);
45
+	}
46
+
47
+	public function redisNotRunning()
48
+	{
49
+		$error = ['status' => 400, 'message' => trans('errors.redisNotRunning')];
50
+		abort($error['status'], $error['message']);
51
+	}
52
+
53
+	public function dbQueryError()
54
+	{
55
+		$error = ['status' => 400, 'message' => trans('errors.dbQueryError')];
56
+		abort($error['status'], $error['message']);
57
+	}
58
+
59
+	public function cannotCreateSetting()
60
+	{
61
+		$error = ['status' => 400, 'message' => trans('errors.cannotCreateSetting')];
62
+		abort($error['status'], $error['message']);
63
+	}
64
+
65
+	public function cannotUpdateSettingKey()
66
+	{
67
+		$error = ['status' => 400, 'message' => trans('errors.cannotUpdateSettingKey')];
68
+		abort($error['status'], $error['message']);
69
+	}
70
+
71
+	public function userIsBlocked()
72
+	{
73
+		$error = ['status' => 403, 'message' => trans('errors.userIsBlocked')];
74
+		abort($error['status'], $error['message']);
75
+	}
76
+
77
+	public function invalidResetToken()
78
+	{
79
+		$error = ['status' => 400, 'message' => trans('errors.invalidResetToken')];
80
+		abort($error['status'], $error['message']);
81
+	}
82
+
83
+	public function invalidResetPassword()
84
+	{
85
+		$error = ['status' => 400, 'message' => trans('errors.invalidResetPassword')];
86
+		abort($error['status'], $error['message']);
87
+	}
88
+
89
+	public function invalidOldPassword()
90
+	{
91
+		$error = ['status' => 400, 'message' => trans('errors.invalidOldPassword')];
92
+		abort($error['status'], $error['message']);
93
+	}
94
+
95
+	public function notFound($text)
96
+	{
97
+		$error = ['status' => 404, 'message' => trans('errors.notFound', ['replace' => $text])];
98
+		abort($error['status'], $error['message']);
99
+	}
100
+
101
+	public function generalError()
102
+	{
103
+		$error = ['status' => 404, 'message' => trans('errors.generalError')];
104
+		abort($error['status'], $error['message']);
105
+	}
106 106
 }
107 107
\ No newline at end of file
Please login to merge, or discard this patch.