diff --git a/app/Exceptions/AuthException.php b/app/Exceptions/AuthException.php new file mode 100644 index 000000000..c20bb62a0 --- /dev/null +++ b/app/Exceptions/AuthException.php @@ -0,0 +1,4 @@ +exists) { + + // Check for users with same email already + $alreadyUser = $user->newQuery()->where('email', '=', $user->email)->count() > 0; + if ($alreadyUser) { + throw new AuthException('A user with the email ' . $user->email . ' already exists but with different credentials.'); + } + $user->save(); $this->userRepo->attachDefaultRole($user); auth()->login($user);