Completed
Push — master ( bfbb50...8023d3 )
by Sherif
09:55
created
src/Modules/Notifications/Notification.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,5 +6,5 @@
 block discarded – undo
6 6
 
7 7
 class Notification extends DatabaseNotification
8 8
 {
9
-    //
9
+	//
10 10
 }
Please login to merge, or discard this patch.
src/Modules/Users/AclUser.php 1 patch
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -12,117 +12,117 @@
 block discarded – undo
12 12
 
13 13
 class AclUser extends User
14 14
 {
15
-    use SoftDeletes, HasApiTokens;
16
-    protected $table    = 'users';
17
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
18
-    protected $hidden   = ['password', 'remember_token', 'deleted_at'];
19
-    protected $guarded  = ['id'];
20
-    protected $fillable = ['profile_picture', 'name', 'email', 'password', 'locale', 'timezone'];
21
-
22
-    /**
23
-     * Get the profile picture url.
24
-     * @return string
25
-     */
26
-    public function getProfilePictureAttribute($value)
27
-    {
28
-        return url(\Storage::url($value));
29
-    }
30
-
31
-    /**
32
-     * Encrypt the password attribute before
33
-     * saving it in the storage.
34
-     *
35
-     * @param string $value
36
-     */
37
-    public function setPasswordAttribute($value)
38
-    {
39
-        $this->attributes['password'] = \Hash::make($value);
40
-    }
41
-
42
-    /**
43
-     * Get the entity's notifications.
44
-     */
45
-    public function notifications()
46
-    {
47
-        return $this->morphMany(Notification::class, 'notifiable')->orderBy('created_at', 'desc');
48
-    }
49
-
50
-    /**
51
-     * Get the entity's read notifications.
52
-     */
53
-    public function readNotifications()
54
-    {
55
-        return $this->notifications()->whereNotNull('read_at');
56
-    }
57
-
58
-    /**
59
-     * Get the entity's unread notifications.
60
-     */
61
-    public function unreadNotifications()
62
-    {
63
-        return $this->notifications()->whereNull('read_at');
64
-    }
65
-
66
-    public function roles()
67
-    {
68
-        return $this->belongsToMany(Role::class, 'role_user', 'user_id', 'role_id')->whereNull('role_user.deleted_at')->withTimestamps();
69
-    }
70
-
71
-    public function oauthClients()
72
-    {
73
-        return $this->hasMany(OauthClient::class, 'user_id');
74
-    }
75
-
76
-    /**
77
-     * Return fcm device tokens that will be used in sending fcm notifications.
78
-     *
79
-     * @return array
80
-     */
81
-    public function routeNotificationForFCM()
82
-    {
83
-        $devices = \Core::pushNotificationDevices()->findBy(['user_id' => $this->id]);
84
-        $tokens  = [];
85
-
86
-        foreach ($devices as $device) {
87
-            if (\Core::oauthClients()->accessTokenExpiredOrRevoked($device->access_token)) {
88
-                $device->forceDelete();
89
-                continue;
90
-            }
91
-
92
-            $tokens[] = $device->device_token;
93
-        }
94
-
95
-        return $tokens;
96
-    }
97
-
98
-    /**
99
-     * The channels the user receives notification broadcasts on.
100
-     *
101
-     * @return string
102
-     */
103
-    public function receivesBroadcastNotificationsOn()
104
-    {
105
-        return 'users.'.$this->id;
106
-    }
107
-
108
-    /**
109
-     * Custom password validation.
110
-     *
111
-     * @param  string $password
112
-     * @return boolean
113
-     */
114
-    public function validateForPassportPasswordGrant($password)
115
-    {
116
-        if ($password == config('skeleton.social_pass')) {
117
-            return true;
118
-        }
119
-
120
-        return \Hash::check($password, $this->password);
121
-    }
15
+	use SoftDeletes, HasApiTokens;
16
+	protected $table    = 'users';
17
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
18
+	protected $hidden   = ['password', 'remember_token', 'deleted_at'];
19
+	protected $guarded  = ['id'];
20
+	protected $fillable = ['profile_picture', 'name', 'email', 'password', 'locale', 'timezone'];
21
+
22
+	/**
23
+	 * Get the profile picture url.
24
+	 * @return string
25
+	 */
26
+	public function getProfilePictureAttribute($value)
27
+	{
28
+		return url(\Storage::url($value));
29
+	}
30
+
31
+	/**
32
+	 * Encrypt the password attribute before
33
+	 * saving it in the storage.
34
+	 *
35
+	 * @param string $value
36
+	 */
37
+	public function setPasswordAttribute($value)
38
+	{
39
+		$this->attributes['password'] = \Hash::make($value);
40
+	}
41
+
42
+	/**
43
+	 * Get the entity's notifications.
44
+	 */
45
+	public function notifications()
46
+	{
47
+		return $this->morphMany(Notification::class, 'notifiable')->orderBy('created_at', 'desc');
48
+	}
49
+
50
+	/**
51
+	 * Get the entity's read notifications.
52
+	 */
53
+	public function readNotifications()
54
+	{
55
+		return $this->notifications()->whereNotNull('read_at');
56
+	}
57
+
58
+	/**
59
+	 * Get the entity's unread notifications.
60
+	 */
61
+	public function unreadNotifications()
62
+	{
63
+		return $this->notifications()->whereNull('read_at');
64
+	}
65
+
66
+	public function roles()
67
+	{
68
+		return $this->belongsToMany(Role::class, 'role_user', 'user_id', 'role_id')->whereNull('role_user.deleted_at')->withTimestamps();
69
+	}
70
+
71
+	public function oauthClients()
72
+	{
73
+		return $this->hasMany(OauthClient::class, 'user_id');
74
+	}
75
+
76
+	/**
77
+	 * Return fcm device tokens that will be used in sending fcm notifications.
78
+	 *
79
+	 * @return array
80
+	 */
81
+	public function routeNotificationForFCM()
82
+	{
83
+		$devices = \Core::pushNotificationDevices()->findBy(['user_id' => $this->id]);
84
+		$tokens  = [];
85
+
86
+		foreach ($devices as $device) {
87
+			if (\Core::oauthClients()->accessTokenExpiredOrRevoked($device->access_token)) {
88
+				$device->forceDelete();
89
+				continue;
90
+			}
91
+
92
+			$tokens[] = $device->device_token;
93
+		}
94
+
95
+		return $tokens;
96
+	}
97
+
98
+	/**
99
+	 * The channels the user receives notification broadcasts on.
100
+	 *
101
+	 * @return string
102
+	 */
103
+	public function receivesBroadcastNotificationsOn()
104
+	{
105
+		return 'users.'.$this->id;
106
+	}
107
+
108
+	/**
109
+	 * Custom password validation.
110
+	 *
111
+	 * @param  string $password
112
+	 * @return boolean
113
+	 */
114
+	public function validateForPassportPasswordGrant($password)
115
+	{
116
+		if ($password == config('skeleton.social_pass')) {
117
+			return true;
118
+		}
119
+
120
+		return \Hash::check($password, $this->password);
121
+	}
122 122
     
123
-    public static function boot()
124
-    {
125
-        parent::boot();
126
-        AclUser::observe(AclUserObserver::class);
127
-    }
123
+	public static function boot()
124
+	{
125
+		parent::boot();
126
+		AclUser::observe(AclUserObserver::class);
127
+	}
128 128
 }
Please login to merge, or discard this patch.
src/Modules/Users/Services/UserService.php 2 patches
Indentation   +365 added lines, -365 removed lines patch added patch discarded remove patch
@@ -12,373 +12,373 @@
 block discarded – undo
12 12
 
13 13
 class UserService extends BaseService
14 14
 {
15
-    /**
16
-     * @var PermissionService
17
-     */
18
-    protected $permissionService;
19
-
20
-    /**
21
-     * @var LoginProxy
22
-     */
23
-    protected $loginProxy;
24
-
25
-    /**
26
-     * @var NotificationService
27
-     */
28
-    protected $notificationService;
29
-
30
-    /**
31
-     * @var OauthClientService
32
-     */
33
-    protected $oauthClientService;
34
-
35
-    /**
36
-     * Init new object.
37
-     *
38
-     * @param   UserRepository       $repo
39
-     * @param   PermissionService    $permissionService
40
-     * @param   LoginProxy           $loginProxy
41
-     * @param   NotificationService  $notificationService
42
-     * @param   OauthClientService   $oauthClientService
43
-     * @return  void
44
-     */
45
-    public function __construct(
46
-        UserRepository $repo,
47
-        PermissionService $permissionService,
48
-        LoginProxy $loginProxy,
49
-        NotificationService $notificationService,
50
-        OauthClientService $oauthClientService
51
-    ) {
52
-        $this->permissionService   = $permissionService;
53
-        $this->loginProxy          = $loginProxy;
54
-        $this->notificationService = $notificationService;
55
-        $this->oauthClientService  = $oauthClientService;
56
-        parent::__construct($repo);
57
-    }
58
-
59
-    /**
60
-     * Return the logged in user account.
61
-     *
62
-     * @param  array   $relations
63
-     * @return boolean
64
-     */
65
-    public function account($relations = ['roles.permissions'])
66
-    {
67
-        $permissions = [];
68
-        $user        = $this->repo->find(\Auth::id(), $relations);
69
-        foreach ($user->roles as $role) {
70
-            $role->permissions->each(function ($permission) use (&$permissions) {
71
-                $permissions[$permission->repo][$permission->id] = $permission->name;
72
-            });
73
-        }
74
-        $user->permissions = $permissions;
75
-
76
-        return $user;
77
-    }
78
-
79
-    /**
80
-     * Check if the logged in user or the given user
81
-     * has the given permissions on the given model.
82
-     *
83
-     * @param  string $permissionName
84
-     * @param  string $model
85
-     * @param  mixed  $userId
86
-     * @return boolean
87
-     */
88
-    public function can($permissionName, $model, $userId = false)
89
-    {
90
-        $permission = $this->permissionService->first([
91
-            'and' => [
92
-                'model' => $model,
93
-                'name'  => $permissionName,
94
-                'roles' => [
95
-                    'op' => 'has',
96
-                    'val' => [
97
-                        'users' => [
98
-                            'op' => 'has',
99
-                            'val' => [
100
-                                'users.id' => $userId ?: \Auth::id()
101
-                            ]
102
-                        ]
103
-                    ]
104
-                ]
105
-            ]
106
-        ]);
107
-
108
-        return $permission ? true : false;
109
-    }
110
-
111
-    /**
112
-     * Check if the logged in or the given user has the given role.
113
-     *
114
-     * @param  string[] $roles
115
-     * @param  mixed    $user
116
-     * @return boolean
117
-     */
118
-    public function hasRoles($roles, $user = false)
119
-    {
120
-        return $this->repo->countRoles($user ?: \Auth::id(), $roles) ? true : false;
121
-    }
122
-
123
-    /**
124
-     * Assign the given role ids to the given user.
125
-     *
126
-     * @param  integer $userId
127
-     * @param  array   $roleIds
128
-     * @return object
129
-     */
130
-    public function assignRoles($userId, $roleIds)
131
-    {
132
-        $user = false;
133
-        \DB::transaction(function () use ($userId, $roleIds, &$user) {
134
-            $user = $this->repo->find($userId);
135
-            $this->repo->detachPermissions($userId);
136
-            $this->repo->attachPermissions($userId, $roleIds);
137
-        });
138
-
139
-        return $user;
140
-    }
141
-
142
-    /**
143
-     * Handle the login request to the application.
144
-     *
145
-     * @param  string  $email
146
-     * @param  string  $password
147
-     * @param  string  $role
148
-     * @return object
149
-     */
150
-    public function login($email, $password, $role = false)
151
-    {
152
-        if (! $user = $this->repo->first(['email' => $email])) {
153
-            \Errors::loginFailed();
154
-        } elseif ($user->blocked) {
155
-            \Errors::userIsBlocked();
156
-        } elseif (! config('skeleton.disable_confirm_email') && ! $user->confirmed) {
157
-            \Errors::emailNotConfirmed();
158
-        }
159
-
160
-        return ['user' => $user, 'tokens' => $this->loginProxy->login($user->email, $password)];
161
-    }
162
-
163
-    /**
164
-     * Handle the social login request to the application.
165
-     *
166
-     * @param  string $authCode
167
-     * @param  string $accessToken
168
-     * @return array
169
-     */
170
-    public function loginSocial($authCode, $accessToken, $type)
171
-    {
172
-        $access_token = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken;
173
-        $user         = \Socialite::driver($type)->userFromToken($access_token);
174
-
175
-        if (! $user->email) {
176
-            \Errors::noSocialEmail();
177
-        }
178
-
179
-        if (! $this->repo->first(['email' => $user->email])) {
180
-            $this->register($user->email, '', true);
181
-        }
182
-
183
-        return $this->loginProxy->login($user->email, config('skeleton.social_pass'));
184
-    }
15
+	/**
16
+	 * @var PermissionService
17
+	 */
18
+	protected $permissionService;
19
+
20
+	/**
21
+	 * @var LoginProxy
22
+	 */
23
+	protected $loginProxy;
24
+
25
+	/**
26
+	 * @var NotificationService
27
+	 */
28
+	protected $notificationService;
29
+
30
+	/**
31
+	 * @var OauthClientService
32
+	 */
33
+	protected $oauthClientService;
34
+
35
+	/**
36
+	 * Init new object.
37
+	 *
38
+	 * @param   UserRepository       $repo
39
+	 * @param   PermissionService    $permissionService
40
+	 * @param   LoginProxy           $loginProxy
41
+	 * @param   NotificationService  $notificationService
42
+	 * @param   OauthClientService   $oauthClientService
43
+	 * @return  void
44
+	 */
45
+	public function __construct(
46
+		UserRepository $repo,
47
+		PermissionService $permissionService,
48
+		LoginProxy $loginProxy,
49
+		NotificationService $notificationService,
50
+		OauthClientService $oauthClientService
51
+	) {
52
+		$this->permissionService   = $permissionService;
53
+		$this->loginProxy          = $loginProxy;
54
+		$this->notificationService = $notificationService;
55
+		$this->oauthClientService  = $oauthClientService;
56
+		parent::__construct($repo);
57
+	}
58
+
59
+	/**
60
+	 * Return the logged in user account.
61
+	 *
62
+	 * @param  array   $relations
63
+	 * @return boolean
64
+	 */
65
+	public function account($relations = ['roles.permissions'])
66
+	{
67
+		$permissions = [];
68
+		$user        = $this->repo->find(\Auth::id(), $relations);
69
+		foreach ($user->roles as $role) {
70
+			$role->permissions->each(function ($permission) use (&$permissions) {
71
+				$permissions[$permission->repo][$permission->id] = $permission->name;
72
+			});
73
+		}
74
+		$user->permissions = $permissions;
75
+
76
+		return $user;
77
+	}
78
+
79
+	/**
80
+	 * Check if the logged in user or the given user
81
+	 * has the given permissions on the given model.
82
+	 *
83
+	 * @param  string $permissionName
84
+	 * @param  string $model
85
+	 * @param  mixed  $userId
86
+	 * @return boolean
87
+	 */
88
+	public function can($permissionName, $model, $userId = false)
89
+	{
90
+		$permission = $this->permissionService->first([
91
+			'and' => [
92
+				'model' => $model,
93
+				'name'  => $permissionName,
94
+				'roles' => [
95
+					'op' => 'has',
96
+					'val' => [
97
+						'users' => [
98
+							'op' => 'has',
99
+							'val' => [
100
+								'users.id' => $userId ?: \Auth::id()
101
+							]
102
+						]
103
+					]
104
+				]
105
+			]
106
+		]);
107
+
108
+		return $permission ? true : false;
109
+	}
110
+
111
+	/**
112
+	 * Check if the logged in or the given user has the given role.
113
+	 *
114
+	 * @param  string[] $roles
115
+	 * @param  mixed    $user
116
+	 * @return boolean
117
+	 */
118
+	public function hasRoles($roles, $user = false)
119
+	{
120
+		return $this->repo->countRoles($user ?: \Auth::id(), $roles) ? true : false;
121
+	}
122
+
123
+	/**
124
+	 * Assign the given role ids to the given user.
125
+	 *
126
+	 * @param  integer $userId
127
+	 * @param  array   $roleIds
128
+	 * @return object
129
+	 */
130
+	public function assignRoles($userId, $roleIds)
131
+	{
132
+		$user = false;
133
+		\DB::transaction(function () use ($userId, $roleIds, &$user) {
134
+			$user = $this->repo->find($userId);
135
+			$this->repo->detachPermissions($userId);
136
+			$this->repo->attachPermissions($userId, $roleIds);
137
+		});
138
+
139
+		return $user;
140
+	}
141
+
142
+	/**
143
+	 * Handle the login request to the application.
144
+	 *
145
+	 * @param  string  $email
146
+	 * @param  string  $password
147
+	 * @param  string  $role
148
+	 * @return object
149
+	 */
150
+	public function login($email, $password, $role = false)
151
+	{
152
+		if (! $user = $this->repo->first(['email' => $email])) {
153
+			\Errors::loginFailed();
154
+		} elseif ($user->blocked) {
155
+			\Errors::userIsBlocked();
156
+		} elseif (! config('skeleton.disable_confirm_email') && ! $user->confirmed) {
157
+			\Errors::emailNotConfirmed();
158
+		}
159
+
160
+		return ['user' => $user, 'tokens' => $this->loginProxy->login($user->email, $password)];
161
+	}
162
+
163
+	/**
164
+	 * Handle the social login request to the application.
165
+	 *
166
+	 * @param  string $authCode
167
+	 * @param  string $accessToken
168
+	 * @return array
169
+	 */
170
+	public function loginSocial($authCode, $accessToken, $type)
171
+	{
172
+		$access_token = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken;
173
+		$user         = \Socialite::driver($type)->userFromToken($access_token);
174
+
175
+		if (! $user->email) {
176
+			\Errors::noSocialEmail();
177
+		}
178
+
179
+		if (! $this->repo->first(['email' => $user->email])) {
180
+			$this->register($user->email, '', true);
181
+		}
182
+
183
+		return $this->loginProxy->login($user->email, config('skeleton.social_pass'));
184
+	}
185 185
     
186
-    /**
187
-     * Handle the registration request.
188
-     *
189
-     * @param  string  $name
190
-     * @param  string  $email
191
-     * @param  string  $password
192
-     * @param  boolean $skipConfirmEmail
193
-     * @return array
194
-     */
195
-    public function register($name, $email, $password, $skipConfirmEmail = false)
196
-    {
197
-        $user = $this->repo->save([
198
-            'name'      => $name,
199
-            'email'     => $email,
200
-            'password'  => $password,
201
-            'confirmed' => $skipConfirmEmail
202
-        ]);
203
-
204
-        if (! $skipConfirmEmail && ! config('skeleton.disable_confirm_email')) {
205
-            $this->sendConfirmationEmail($user->email);
206
-        }
207
-
208
-        return $user;
209
-    }
186
+	/**
187
+	 * Handle the registration request.
188
+	 *
189
+	 * @param  string  $name
190
+	 * @param  string  $email
191
+	 * @param  string  $password
192
+	 * @param  boolean $skipConfirmEmail
193
+	 * @return array
194
+	 */
195
+	public function register($name, $email, $password, $skipConfirmEmail = false)
196
+	{
197
+		$user = $this->repo->save([
198
+			'name'      => $name,
199
+			'email'     => $email,
200
+			'password'  => $password,
201
+			'confirmed' => $skipConfirmEmail
202
+		]);
203
+
204
+		if (! $skipConfirmEmail && ! config('skeleton.disable_confirm_email')) {
205
+			$this->sendConfirmationEmail($user->email);
206
+		}
207
+
208
+		return $user;
209
+	}
210 210
     
211
-    /**
212
-     * Block the user.
213
-     *
214
-     * @param  integer $userId
215
-     * @return object
216
-     */
217
-    public function block($userId)
218
-    {
219
-        if (\Auth::id() == $userId) {
220
-            \Errors::noPermissions();
221
-        }
211
+	/**
212
+	 * Block the user.
213
+	 *
214
+	 * @param  integer $userId
215
+	 * @return object
216
+	 */
217
+	public function block($userId)
218
+	{
219
+		if (\Auth::id() == $userId) {
220
+			\Errors::noPermissions();
221
+		}
222 222
         
223
-        return $this->repo->save(['id' => $userId, 'blocked' => 1]);
224
-    }
225
-
226
-    /**
227
-     * Unblock the user.
228
-     *
229
-     * @param  integer $userId
230
-     * @return object
231
-     */
232
-    public function unblock($userId)
233
-    {
234
-        return $this->repo->save(['id' => $userId, 'blocked' => 0]);
235
-    }
236
-
237
-    /**
238
-     * Send a reset link to the given user.
239
-     *
240
-     * @param  string  $email
241
-     * @return void
242
-     */
243
-    public function sendReset($email)
244
-    {
245
-        if (! $user = $this->repo->first(['email' => $email])) {
246
-            \Errors::notFound('email');
247
-        }
248
-
249
-        $token = \Password::getService()->create($user);
250
-        $this->notificationService->notify($user, 'ResetPassword', $token);
251
-    }
252
-
253
-    /**
254
-     * Reset the given user's password.
255
-     *
256
-     * @param   string  $email
257
-     * @param   string  $password
258
-     * @param   string  $passwordConfirmation
259
-     * @param   string  $token
260
-     * @return string|void
261
-     */
262
-    public function resetPassword($email, $password, $passwordConfirmation, $token)
263
-    {
264
-        $response = \Password::reset([
265
-            'email'                 => $email,
266
-            'password'              => $password,
267
-            'password_confirmation' => $passwordConfirmation,
268
-            'token'                 => $token
269
-        ], function ($user, $password) {
270
-            $this->repo->save(['id' => $user->id, 'password' => $password]);
271
-        });
272
-
273
-        switch ($response) {
274
-            case \Password::PASSWORD_RESET:
275
-                return 'success';
276
-                break;
277
-
278
-            case \Password::INVALID_TOKEN:
279
-                \Errors::invalidResetToken();
280
-                break;
281
-
282
-            case \Password::INVALID_PASSWORD:
283
-                \Errors::invalidResetPassword();
284
-                break;
285
-
286
-            case \Password::INVALID_USER:
287
-                \Errors::notFound('user');
288
-                break;
289
-        }
290
-    }
291
-
292
-    /**
293
-     * Change the logged in user password.
294
-     *
295
-     * @param  string  $password
296
-     * @param  string  $oldPassword
297
-     * @return void
298
-     */
299
-    public function changePassword($password, $oldPassword)
300
-    {
301
-        $user = \Auth::user();
302
-        if (! \Hash::check($oldPassword, $user->password)) {
303
-            \Errors::invalidOldPassword();
304
-        }
305
-
306
-        $this->repo->save(['id' => $user->id, 'password' => $password]);
307
-    }
308
-
309
-    /**
310
-     * Confirm email using the confirmation code.
311
-     *
312
-     * @param  string $confirmationCode
313
-     * @return void
314
-     */
315
-    public function confirmEmail($confirmationCode)
316
-    {
317
-        if (! $user = $this->repo->first(['confirmation_code' => $confirmationCode])) {
318
-            \Errors::invalidConfirmationCode();
319
-        }
320
-
321
-        $this->repo->save(['id' => $user->id, 'confirmed' => 1, 'confirmation_code' => null]);
322
-    }
323
-
324
-    /**
325
-     * Send the confirmation mail.
326
-     *
327
-     * @param  string $email
328
-     * @return void
329
-     */
330
-    public function sendConfirmationEmail($email)
331
-    {
332
-        $user = $this->repo->first(['email' => $email]);
333
-        if ($user->confirmed) {
334
-            \Errors::emailAlreadyConfirmed();
335
-        }
336
-
337
-        $this->repo->save(['id' => $user->id, 'confirmation_code' => sha1(microtime())]);
338
-        $this->notificationService->notify($user, 'ConfirmEmail');
339
-    }
340
-
341
-    /**
342
-     * Save the given data to the logged in user.
343
-     *
344
-     * @param  string $name
345
-     * @param  string $email
346
-     * @param  string $profilePicture
347
-     * @return void
348
-     */
349
-    public function saveProfile($name, $email, $profilePicture = false)
350
-    {
351
-        if ($profilePicture) {
352
-            $data['profile_picture'] = \Media::uploadImageBas64($profilePicture, 'users/profile_pictures');
353
-        }
223
+		return $this->repo->save(['id' => $userId, 'blocked' => 1]);
224
+	}
225
+
226
+	/**
227
+	 * Unblock the user.
228
+	 *
229
+	 * @param  integer $userId
230
+	 * @return object
231
+	 */
232
+	public function unblock($userId)
233
+	{
234
+		return $this->repo->save(['id' => $userId, 'blocked' => 0]);
235
+	}
236
+
237
+	/**
238
+	 * Send a reset link to the given user.
239
+	 *
240
+	 * @param  string  $email
241
+	 * @return void
242
+	 */
243
+	public function sendReset($email)
244
+	{
245
+		if (! $user = $this->repo->first(['email' => $email])) {
246
+			\Errors::notFound('email');
247
+		}
248
+
249
+		$token = \Password::getService()->create($user);
250
+		$this->notificationService->notify($user, 'ResetPassword', $token);
251
+	}
252
+
253
+	/**
254
+	 * Reset the given user's password.
255
+	 *
256
+	 * @param   string  $email
257
+	 * @param   string  $password
258
+	 * @param   string  $passwordConfirmation
259
+	 * @param   string  $token
260
+	 * @return string|void
261
+	 */
262
+	public function resetPassword($email, $password, $passwordConfirmation, $token)
263
+	{
264
+		$response = \Password::reset([
265
+			'email'                 => $email,
266
+			'password'              => $password,
267
+			'password_confirmation' => $passwordConfirmation,
268
+			'token'                 => $token
269
+		], function ($user, $password) {
270
+			$this->repo->save(['id' => $user->id, 'password' => $password]);
271
+		});
272
+
273
+		switch ($response) {
274
+			case \Password::PASSWORD_RESET:
275
+				return 'success';
276
+				break;
277
+
278
+			case \Password::INVALID_TOKEN:
279
+				\Errors::invalidResetToken();
280
+				break;
281
+
282
+			case \Password::INVALID_PASSWORD:
283
+				\Errors::invalidResetPassword();
284
+				break;
285
+
286
+			case \Password::INVALID_USER:
287
+				\Errors::notFound('user');
288
+				break;
289
+		}
290
+	}
291
+
292
+	/**
293
+	 * Change the logged in user password.
294
+	 *
295
+	 * @param  string  $password
296
+	 * @param  string  $oldPassword
297
+	 * @return void
298
+	 */
299
+	public function changePassword($password, $oldPassword)
300
+	{
301
+		$user = \Auth::user();
302
+		if (! \Hash::check($oldPassword, $user->password)) {
303
+			\Errors::invalidOldPassword();
304
+		}
305
+
306
+		$this->repo->save(['id' => $user->id, 'password' => $password]);
307
+	}
308
+
309
+	/**
310
+	 * Confirm email using the confirmation code.
311
+	 *
312
+	 * @param  string $confirmationCode
313
+	 * @return void
314
+	 */
315
+	public function confirmEmail($confirmationCode)
316
+	{
317
+		if (! $user = $this->repo->first(['confirmation_code' => $confirmationCode])) {
318
+			\Errors::invalidConfirmationCode();
319
+		}
320
+
321
+		$this->repo->save(['id' => $user->id, 'confirmed' => 1, 'confirmation_code' => null]);
322
+	}
323
+
324
+	/**
325
+	 * Send the confirmation mail.
326
+	 *
327
+	 * @param  string $email
328
+	 * @return void
329
+	 */
330
+	public function sendConfirmationEmail($email)
331
+	{
332
+		$user = $this->repo->first(['email' => $email]);
333
+		if ($user->confirmed) {
334
+			\Errors::emailAlreadyConfirmed();
335
+		}
336
+
337
+		$this->repo->save(['id' => $user->id, 'confirmation_code' => sha1(microtime())]);
338
+		$this->notificationService->notify($user, 'ConfirmEmail');
339
+	}
340
+
341
+	/**
342
+	 * Save the given data to the logged in user.
343
+	 *
344
+	 * @param  string $name
345
+	 * @param  string $email
346
+	 * @param  string $profilePicture
347
+	 * @return void
348
+	 */
349
+	public function saveProfile($name, $email, $profilePicture = false)
350
+	{
351
+		if ($profilePicture) {
352
+			$data['profile_picture'] = \Media::uploadImageBas64($profilePicture, 'users/profile_pictures');
353
+		}
354 354
         
355
-        $data['id'] = \Auth::id();
356
-        return $this->repo->save([
357
-            'id'             => \Auth::id(),
358
-            'name'           => $name,
359
-            'email'          => $email,
360
-            'profilePicture' => $profilePicture,
361
-        ]);
362
-    }
363
-
364
-    /**
365
-     * Logs out the user, revoke access token and refresh token.
366
-     *
367
-     * @return void
368
-     */
369
-    public function logout()
370
-    {
371
-        $this->oauthClientService->revokeAccessToken(\Auth::user()->token());
372
-    }
373
-
374
-    /**
375
-     * Attempt to refresh the access token using the given refresh token.
376
-     *
377
-     * @param  string $refreshToken
378
-     * @return array
379
-     */
380
-    public function refreshToken($refreshToken)
381
-    {
382
-        return $this->loginProxy->refreshToken($refreshToken);
383
-    }
355
+		$data['id'] = \Auth::id();
356
+		return $this->repo->save([
357
+			'id'             => \Auth::id(),
358
+			'name'           => $name,
359
+			'email'          => $email,
360
+			'profilePicture' => $profilePicture,
361
+		]);
362
+	}
363
+
364
+	/**
365
+	 * Logs out the user, revoke access token and refresh token.
366
+	 *
367
+	 * @return void
368
+	 */
369
+	public function logout()
370
+	{
371
+		$this->oauthClientService->revokeAccessToken(\Auth::user()->token());
372
+	}
373
+
374
+	/**
375
+	 * Attempt to refresh the access token using the given refresh token.
376
+	 *
377
+	 * @param  string $refreshToken
378
+	 * @return array
379
+	 */
380
+	public function refreshToken($refreshToken)
381
+	{
382
+		return $this->loginProxy->refreshToken($refreshToken);
383
+	}
384 384
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         $permissions = [];
68 68
         $user        = $this->repo->find(\Auth::id(), $relations);
69 69
         foreach ($user->roles as $role) {
70
-            $role->permissions->each(function ($permission) use (&$permissions) {
70
+            $role->permissions->each(function($permission) use (&$permissions) {
71 71
                 $permissions[$permission->repo][$permission->id] = $permission->name;
72 72
             });
73 73
         }
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     public function assignRoles($userId, $roleIds)
131 131
     {
132 132
         $user = false;
133
-        \DB::transaction(function () use ($userId, $roleIds, &$user) {
133
+        \DB::transaction(function() use ($userId, $roleIds, &$user) {
134 134
             $user = $this->repo->find($userId);
135 135
             $this->repo->detachPermissions($userId);
136 136
             $this->repo->attachPermissions($userId, $roleIds);
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
      */
150 150
     public function login($email, $password, $role = false)
151 151
     {
152
-        if (! $user = $this->repo->first(['email' => $email])) {
152
+        if ( ! $user = $this->repo->first(['email' => $email])) {
153 153
             \Errors::loginFailed();
154 154
         } elseif ($user->blocked) {
155 155
             \Errors::userIsBlocked();
156
-        } elseif (! config('skeleton.disable_confirm_email') && ! $user->confirmed) {
156
+        } elseif ( ! config('skeleton.disable_confirm_email') && ! $user->confirmed) {
157 157
             \Errors::emailNotConfirmed();
158 158
         }
159 159
 
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
         $access_token = $authCode ? Arr::get(\Socialite::driver($type)->getAccessTokenResponse($authCode), 'access_token') : $accessToken;
173 173
         $user         = \Socialite::driver($type)->userFromToken($access_token);
174 174
 
175
-        if (! $user->email) {
175
+        if ( ! $user->email) {
176 176
             \Errors::noSocialEmail();
177 177
         }
178 178
 
179
-        if (! $this->repo->first(['email' => $user->email])) {
179
+        if ( ! $this->repo->first(['email' => $user->email])) {
180 180
             $this->register($user->email, '', true);
181 181
         }
182 182
 
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
             'confirmed' => $skipConfirmEmail
202 202
         ]);
203 203
 
204
-        if (! $skipConfirmEmail && ! config('skeleton.disable_confirm_email')) {
204
+        if ( ! $skipConfirmEmail && ! config('skeleton.disable_confirm_email')) {
205 205
             $this->sendConfirmationEmail($user->email);
206 206
         }
207 207
 
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
      */
243 243
     public function sendReset($email)
244 244
     {
245
-        if (! $user = $this->repo->first(['email' => $email])) {
245
+        if ( ! $user = $this->repo->first(['email' => $email])) {
246 246
             \Errors::notFound('email');
247 247
         }
248 248
 
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
             'password'              => $password,
267 267
             'password_confirmation' => $passwordConfirmation,
268 268
             'token'                 => $token
269
-        ], function ($user, $password) {
269
+        ], function($user, $password) {
270 270
             $this->repo->save(['id' => $user->id, 'password' => $password]);
271 271
         });
272 272
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
     public function changePassword($password, $oldPassword)
300 300
     {
301 301
         $user = \Auth::user();
302
-        if (! \Hash::check($oldPassword, $user->password)) {
302
+        if ( ! \Hash::check($oldPassword, $user->password)) {
303 303
             \Errors::invalidOldPassword();
304 304
         }
305 305
 
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
      */
315 315
     public function confirmEmail($confirmationCode)
316 316
     {
317
-        if (! $user = $this->repo->first(['confirmation_code' => $confirmationCode])) {
317
+        if ( ! $user = $this->repo->first(['confirmation_code' => $confirmationCode])) {
318 318
             \Errors::invalidConfirmationCode();
319 319
         }
320 320
 
Please login to merge, or discard this patch.
src/Modules/Users/Http/Requests/Login.php 1 patch
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -6,26 +6,26 @@
 block discarded – undo
6 6
 
7 7
 class Login extends FormRequest
8 8
 {
9
-    /**
10
-     * Determine if the user is authorized to make this request.
11
-     *
12
-     * @return bool
13
-     */
14
-    public function authorize()
15
-    {
16
-        return true;
17
-    }
9
+	/**
10
+	 * Determine if the user is authorized to make this request.
11
+	 *
12
+	 * @return bool
13
+	 */
14
+	public function authorize()
15
+	{
16
+		return true;
17
+	}
18 18
 
19
-    /**
20
-     * Get the validation rules that apply to the request.
21
-     *
22
-     * @return array
23
-     */
24
-    public function rules()
25
-    {
26
-        return [
27
-            'email'    => 'required|email',
28
-            'password' => 'required|min:6'
29
-        ];
30
-    }
19
+	/**
20
+	 * Get the validation rules that apply to the request.
21
+	 *
22
+	 * @return array
23
+	 */
24
+	public function rules()
25
+	{
26
+		return [
27
+			'email'    => 'required|email',
28
+			'password' => 'required|min:6'
29
+		];
30
+	}
31 31
 }
Please login to merge, or discard this patch.
src/Modules/Users/Http/Controllers/UserController.php 1 patch
Indentation   +221 added lines, -221 removed lines patch added patch discarded remove patch
@@ -24,225 +24,225 @@
 block discarded – undo
24 24
 
25 25
 class UserController extends BaseApiController
26 26
 {
27
-    /**
28
-     * Path of the model resource
29
-     *
30
-     * @var string
31
-     */
32
-    protected $modelResource = 'App\Modules\Users\Http\Resources\AclUser';
33
-
34
-    /**
35
-     * List of all route actions that the base api controller
36
-     * will skip permissions check for them.
37
-     * @var array
38
-     */
39
-    protected $skipPermissionCheck = ['account', 'logout', 'changePassword', 'saveProfile'];
40
-
41
-    /**
42
-     * List of all route actions that the base api controller
43
-     * will skip login check for them.
44
-     * @var array
45
-     */
46
-    protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendReset', 'resetPassword', 'refreshToken', 'confirmEmail', 'resendEmailConfirmation'];
47
-
48
-    /**
49
-     * Init new object.
50
-     *
51
-     * @param   UserService $service
52
-     * @return  void
53
-     */
54
-    public function __construct(UserService $service)
55
-    {
56
-        parent::__construct($service);
57
-    }
58
-
59
-    /**
60
-     * Insert the given model to storage.
61
-     *
62
-     * @param InsertUser $request
63
-     * @return \Illuminate\Http\Response
64
-     */
65
-    public function insert(InsertUser $request)
66
-    {
67
-        return new $this->modelResource($this->service->save($request->all()));
68
-    }
69
-
70
-    /**
71
-     * Update the given model to storage.
72
-     *
73
-     * @param UpdateUser $request
74
-     * @return \Illuminate\Http\Response
75
-     */
76
-    public function update(UpdateUser $request)
77
-    {
78
-        return new $this->modelResource($this->service->save($request->all()));
79
-    }
80
-
81
-    /**
82
-     * Return the logged in user account.
83
-     *
84
-     * @param Request $request
85
-     * @return \Illuminate\Http\Response
86
-     */
87
-    public function account(Request $request)
88
-    {
89
-        return new $this->modelResource($this->service->account($request->relations));
90
-    }
91
-
92
-    /**
93
-     * Block the user.
94
-     *
95
-     * @param  integer  $id Id of the user.
96
-     * @return \Illuminate\Http\Response
97
-     */
98
-    public function block($id)
99
-    {
100
-        return new $this->modelResource($this->service->block($id));
101
-    }
102
-
103
-    /**
104
-     * Unblock the user.
105
-     *
106
-     * @param  integer  $id Id of the user.
107
-     * @return \Illuminate\Http\Response
108
-     */
109
-    public function unblock($id)
110
-    {
111
-        return new $this->modelResource($this->service->unblock($id));
112
-    }
113
-
114
-    /**
115
-     * Logout the user.
116
-     *
117
-     * @return \Illuminate\Http\Response
118
-     */
119
-    public function logout()
120
-    {
121
-        return new GeneralResource($this->service->logout());
122
-    }
123
-
124
-    /**
125
-     * Handle the registration request.
126
-     *
127
-     * @param Register $request
128
-     * @return \Illuminate\Http\Response
129
-     */
130
-    public function register(Register $request)
131
-    {
132
-        return new $this->modelResource($this->service->register($request->get('name'), $request->get('email'), $request->get('password')));
133
-    }
134
-
135
-    /**
136
-     * Handle the login request to the application.
137
-     *
138
-     * @param Login $request
139
-     * @return \Illuminate\Http\Response
140
-     */
141
-    public function login(Login $request)
142
-    {
143
-        $result = $this->service->login($request->get('email'), $request->get('password'));
144
-
145
-        return (new $this->modelResource($result['user']))->additional(['meta' => $result['tokens']]);
146
-    }
147
-
148
-    /**
149
-     * Handle the social login request the application.
150
-     *
151
-     * @param LoginSocial $request
152
-     * @return \Illuminate\Http\Response
153
-     */
154
-    public function loginSocial(LoginSocial $request)
155
-    {
156
-        $result = $this->service->loginSocial($request->get('auth_code'), $request->get('access_token'), $request->get('type'));
157
-
158
-        return (new $this->modelResource($result['user']))->additional(['meta' => $result['tokens']]);
159
-    }
160
-
161
-    /**
162
-     * Assign the given roles to the given user.
163
-     *
164
-     * @param AssignRoles $request
165
-     * @return \Illuminate\Http\Response
166
-     */
167
-    public function assignRoles(AssignRoles $request)
168
-    {
169
-        return new $this->modelResource($this->service->assignRoles($request->get('user_id'), $request->get('role_ids')));
170
-    }
171
-
172
-    /**
173
-     * Send a reset link to the given user.
174
-     *
175
-     * @param SendReset $request
176
-     * @return \Illuminate\Http\Response
177
-     */
178
-    public function sendReset(SendReset $request)
179
-    {
180
-        return new GeneralResource($this->service->sendReset($request->get('email')));
181
-    }
182
-
183
-    /**
184
-     * Reset the given user's password.
185
-     *
186
-     * @param ResetPassword $request
187
-     * @return \Illuminate\Http\Response
188
-     */
189
-    public function resetPassword(ResetPassword $request)
190
-    {
191
-        return new GeneralResource($this->service->resetPassword($request->get('email'), $request->get('password'), $request->get('password_confirmation'), $request->get('token')));
192
-    }
193
-
194
-    /**
195
-     * Change the logged in user password.
196
-     *
197
-     * @param ChangePassword $request
198
-     * @return \Illuminate\Http\Response
199
-     */
200
-    public function changePassword(ChangePassword $request)
201
-    {
202
-        return new GeneralResource($this->service->changePassword($request->get('password'), $request->get('old_password')));
203
-    }
204
-
205
-    /**
206
-     * Confirm email using the confirmation code.
207
-     *
208
-     * @param ConfirmEmail $request
209
-     * @return \Illuminate\Http\Response
210
-     */
211
-    public function confirmEmail(ConfirmEmail $request)
212
-    {
213
-        return new GeneralResource($this->service->confirmEmail($request->only('confirmation_code')));
214
-    }
215
-
216
-    /**
217
-     * Resend the email confirmation mail.
218
-     *
219
-     * @param ResendEmailConfirmation $request
220
-     * @return \Illuminate\Http\Response
221
-     */
222
-    public function resendEmailConfirmation(ResendEmailConfirmation $request)
223
-    {
224
-        return new GeneralResource($this->service->sendConfirmationEmail($request->get('email')));
225
-    }
226
-
227
-    /**
228
-     * Refresh the expired login token.
229
-     *
230
-     * @param RefreshToken $request
231
-     * @return \Illuminate\Http\Response
232
-     */
233
-    public function refreshToken(RefreshToken $request)
234
-    {
235
-        return new GeneralResource($this->service->refreshToken($request->get('refresh_token')));
236
-    }
237
-
238
-    /**
239
-     * Save the given data to the logged in user.
240
-     *
241
-     * @param SaveProfile $request
242
-     * @return \Illuminate\Http\Response
243
-     */
244
-    public function saveProfile(SaveProfile $request)
245
-    {
246
-        return new $this->modelResource($this->service->saveProfile($request->get('name'), $request->get('email'), $request->get('profile_picture')));
247
-    }
27
+	/**
28
+	 * Path of the model resource
29
+	 *
30
+	 * @var string
31
+	 */
32
+	protected $modelResource = 'App\Modules\Users\Http\Resources\AclUser';
33
+
34
+	/**
35
+	 * List of all route actions that the base api controller
36
+	 * will skip permissions check for them.
37
+	 * @var array
38
+	 */
39
+	protected $skipPermissionCheck = ['account', 'logout', 'changePassword', 'saveProfile'];
40
+
41
+	/**
42
+	 * List of all route actions that the base api controller
43
+	 * will skip login check for them.
44
+	 * @var array
45
+	 */
46
+	protected $skipLoginCheck = ['login', 'loginSocial', 'register', 'sendReset', 'resetPassword', 'refreshToken', 'confirmEmail', 'resendEmailConfirmation'];
47
+
48
+	/**
49
+	 * Init new object.
50
+	 *
51
+	 * @param   UserService $service
52
+	 * @return  void
53
+	 */
54
+	public function __construct(UserService $service)
55
+	{
56
+		parent::__construct($service);
57
+	}
58
+
59
+	/**
60
+	 * Insert the given model to storage.
61
+	 *
62
+	 * @param InsertUser $request
63
+	 * @return \Illuminate\Http\Response
64
+	 */
65
+	public function insert(InsertUser $request)
66
+	{
67
+		return new $this->modelResource($this->service->save($request->all()));
68
+	}
69
+
70
+	/**
71
+	 * Update the given model to storage.
72
+	 *
73
+	 * @param UpdateUser $request
74
+	 * @return \Illuminate\Http\Response
75
+	 */
76
+	public function update(UpdateUser $request)
77
+	{
78
+		return new $this->modelResource($this->service->save($request->all()));
79
+	}
80
+
81
+	/**
82
+	 * Return the logged in user account.
83
+	 *
84
+	 * @param Request $request
85
+	 * @return \Illuminate\Http\Response
86
+	 */
87
+	public function account(Request $request)
88
+	{
89
+		return new $this->modelResource($this->service->account($request->relations));
90
+	}
91
+
92
+	/**
93
+	 * Block the user.
94
+	 *
95
+	 * @param  integer  $id Id of the user.
96
+	 * @return \Illuminate\Http\Response
97
+	 */
98
+	public function block($id)
99
+	{
100
+		return new $this->modelResource($this->service->block($id));
101
+	}
102
+
103
+	/**
104
+	 * Unblock the user.
105
+	 *
106
+	 * @param  integer  $id Id of the user.
107
+	 * @return \Illuminate\Http\Response
108
+	 */
109
+	public function unblock($id)
110
+	{
111
+		return new $this->modelResource($this->service->unblock($id));
112
+	}
113
+
114
+	/**
115
+	 * Logout the user.
116
+	 *
117
+	 * @return \Illuminate\Http\Response
118
+	 */
119
+	public function logout()
120
+	{
121
+		return new GeneralResource($this->service->logout());
122
+	}
123
+
124
+	/**
125
+	 * Handle the registration request.
126
+	 *
127
+	 * @param Register $request
128
+	 * @return \Illuminate\Http\Response
129
+	 */
130
+	public function register(Register $request)
131
+	{
132
+		return new $this->modelResource($this->service->register($request->get('name'), $request->get('email'), $request->get('password')));
133
+	}
134
+
135
+	/**
136
+	 * Handle the login request to the application.
137
+	 *
138
+	 * @param Login $request
139
+	 * @return \Illuminate\Http\Response
140
+	 */
141
+	public function login(Login $request)
142
+	{
143
+		$result = $this->service->login($request->get('email'), $request->get('password'));
144
+
145
+		return (new $this->modelResource($result['user']))->additional(['meta' => $result['tokens']]);
146
+	}
147
+
148
+	/**
149
+	 * Handle the social login request the application.
150
+	 *
151
+	 * @param LoginSocial $request
152
+	 * @return \Illuminate\Http\Response
153
+	 */
154
+	public function loginSocial(LoginSocial $request)
155
+	{
156
+		$result = $this->service->loginSocial($request->get('auth_code'), $request->get('access_token'), $request->get('type'));
157
+
158
+		return (new $this->modelResource($result['user']))->additional(['meta' => $result['tokens']]);
159
+	}
160
+
161
+	/**
162
+	 * Assign the given roles to the given user.
163
+	 *
164
+	 * @param AssignRoles $request
165
+	 * @return \Illuminate\Http\Response
166
+	 */
167
+	public function assignRoles(AssignRoles $request)
168
+	{
169
+		return new $this->modelResource($this->service->assignRoles($request->get('user_id'), $request->get('role_ids')));
170
+	}
171
+
172
+	/**
173
+	 * Send a reset link to the given user.
174
+	 *
175
+	 * @param SendReset $request
176
+	 * @return \Illuminate\Http\Response
177
+	 */
178
+	public function sendReset(SendReset $request)
179
+	{
180
+		return new GeneralResource($this->service->sendReset($request->get('email')));
181
+	}
182
+
183
+	/**
184
+	 * Reset the given user's password.
185
+	 *
186
+	 * @param ResetPassword $request
187
+	 * @return \Illuminate\Http\Response
188
+	 */
189
+	public function resetPassword(ResetPassword $request)
190
+	{
191
+		return new GeneralResource($this->service->resetPassword($request->get('email'), $request->get('password'), $request->get('password_confirmation'), $request->get('token')));
192
+	}
193
+
194
+	/**
195
+	 * Change the logged in user password.
196
+	 *
197
+	 * @param ChangePassword $request
198
+	 * @return \Illuminate\Http\Response
199
+	 */
200
+	public function changePassword(ChangePassword $request)
201
+	{
202
+		return new GeneralResource($this->service->changePassword($request->get('password'), $request->get('old_password')));
203
+	}
204
+
205
+	/**
206
+	 * Confirm email using the confirmation code.
207
+	 *
208
+	 * @param ConfirmEmail $request
209
+	 * @return \Illuminate\Http\Response
210
+	 */
211
+	public function confirmEmail(ConfirmEmail $request)
212
+	{
213
+		return new GeneralResource($this->service->confirmEmail($request->only('confirmation_code')));
214
+	}
215
+
216
+	/**
217
+	 * Resend the email confirmation mail.
218
+	 *
219
+	 * @param ResendEmailConfirmation $request
220
+	 * @return \Illuminate\Http\Response
221
+	 */
222
+	public function resendEmailConfirmation(ResendEmailConfirmation $request)
223
+	{
224
+		return new GeneralResource($this->service->sendConfirmationEmail($request->get('email')));
225
+	}
226
+
227
+	/**
228
+	 * Refresh the expired login token.
229
+	 *
230
+	 * @param RefreshToken $request
231
+	 * @return \Illuminate\Http\Response
232
+	 */
233
+	public function refreshToken(RefreshToken $request)
234
+	{
235
+		return new GeneralResource($this->service->refreshToken($request->get('refresh_token')));
236
+	}
237
+
238
+	/**
239
+	 * Save the given data to the logged in user.
240
+	 *
241
+	 * @param SaveProfile $request
242
+	 * @return \Illuminate\Http\Response
243
+	 */
244
+	public function saveProfile(SaveProfile $request)
245
+	{
246
+		return new $this->modelResource($this->service->saveProfile($request->get('name'), $request->get('email'), $request->get('profile_picture')));
247
+	}
248 248
 }
Please login to merge, or discard this patch.
src/Modules/OauthClients/OauthClient.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -8,17 +8,17 @@
 block discarded – undo
8 8
 
9 9
 class OauthClient extends Client
10 10
 {
11
-    protected $dates    = ['created_at', 'updated_at'];
12
-    protected $fillable = ['name', 'redirect', 'user_id', 'personal_access_client', 'password_client', 'revoked'];
11
+	protected $dates    = ['created_at', 'updated_at'];
12
+	protected $fillable = ['name', 'redirect', 'user_id', 'personal_access_client', 'password_client', 'revoked'];
13 13
     
14
-    public function user()
15
-    {
16
-        return $this->belongsTo(AclUser::class);
17
-    }
14
+	public function user()
15
+	{
16
+		return $this->belongsTo(AclUser::class);
17
+	}
18 18
     
19
-    public static function boot()
20
-    {
21
-        parent::boot();
22
-        OauthClient::observe(OauthClientObserver::class);
23
-    }
19
+	public static function boot()
20
+	{
21
+		parent::boot();
22
+		OauthClient::observe(OauthClientObserver::class);
23
+	}
24 24
 }
Please login to merge, or discard this patch.
src/Modules/Roles/Role.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -11,26 +11,26 @@
 block discarded – undo
11 11
 class Role extends Model
12 12
 {
13 13
 
14
-    use SoftDeletes;
15
-    protected $table    = 'roles';
16
-    protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
17
-    protected $hidden   = ['deleted_at'];
18
-    protected $guarded  = ['id'];
19
-    protected $fillable = ['name'];
14
+	use SoftDeletes;
15
+	protected $table    = 'roles';
16
+	protected $dates    = ['created_at', 'updated_at', 'deleted_at'];
17
+	protected $hidden   = ['deleted_at'];
18
+	protected $guarded  = ['id'];
19
+	protected $fillable = ['name'];
20 20
 
21
-    public function users()
22
-    {
23
-        return $this->belongsToMany(AclUser::class, 'role_user', 'role_id', 'user_id')->whereNull('role_user.deleted_at')->withTimestamps();
24
-    }
21
+	public function users()
22
+	{
23
+		return $this->belongsToMany(AclUser::class, 'role_user', 'role_id', 'user_id')->whereNull('role_user.deleted_at')->withTimestamps();
24
+	}
25 25
 
26
-    public function permissions()
27
-    {
28
-        return $this->belongsToMany(Permission::class, 'permission_role', 'role_id', 'permission_id')->whereNull('permission_role.deleted_at')->withTimestamps();
29
-    }
26
+	public function permissions()
27
+	{
28
+		return $this->belongsToMany(Permission::class, 'permission_role', 'role_id', 'permission_id')->whereNull('permission_role.deleted_at')->withTimestamps();
29
+	}
30 30
 
31
-    public static function boot()
32
-    {
33
-        parent::boot();
34
-        Role::observe(RoleObserver::class);
35
-    }
31
+	public static function boot()
32
+	{
33
+		parent::boot();
34
+		Role::observe(RoleObserver::class);
35
+	}
36 36
 }
Please login to merge, or discard this patch.