Skip to content

Commit d95b0bc

Browse files
Merge pull request #410 from vidhyut-pandya/develop
Issue : #354
2 parents 192286f + cab554f commit d95b0bc

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

app/Repositories/Backend/Access/User/UserRepository.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ public function create($request)
9696
$permissions = $request->get('permissions');
9797
$user = $this->createUserStub($data);
9898

99+
$this->checkUserByEmail($data, $user);
100+
99101
DB::transaction(function () use ($user, $data, $roles, $permissions) {
100102
if ($user->save()) {
101103

@@ -323,15 +325,19 @@ public function mark($user, $status)
323325
* @param $user
324326
*
325327
* @throws GeneralException
328+
*
329+
* @return null
326330
*/
327-
protected function checkUserByEmail($input, $user)
331+
protected function checkUserByEmail($input, $user = null)
328332
{
329333
//Figure out if email is not the same
330-
if ($user->email != $input['email']) {
331-
//Check to see if email exists
332-
if ($this->query()->where('email', '=', $input['email'])->first()) {
333-
throw new GeneralException(trans('exceptions.backend.access.users.email_error'));
334-
}
334+
if ($user && $user->email === $input['email']) {
335+
return;
336+
}
337+
338+
//Check to see if email exists
339+
if ($this->query()->where('email', '=', $input['email'])->withTrashed()->exists()) {
340+
throw new GeneralException(trans('exceptions.backend.access.users.email_error'));
335341
}
336342
}
337343

0 commit comments

Comments
 (0)