X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/b94b945fb03e21a1997cfe6e50148967586cb26d..refs/pull/2393/head:/app/Auth/Access/RegistrationService.php diff --git a/app/Auth/Access/RegistrationService.php b/app/Auth/Access/RegistrationService.php index 8cf76013a..2aff6c37d 100644 --- a/app/Auth/Access/RegistrationService.php +++ b/app/Auth/Access/RegistrationService.php @@ -1,9 +1,11 @@ userRepo->getByEmail($userEmail)); if ($alreadyUser) { - throw new UserRegistrationException(trans('errors.error_user_exists_different_creds', ['email' => $userEmail])); + throw new UserRegistrationException(trans('errors.error_user_exists_different_creds', ['email' => $userEmail]), '/login'); } // Create the user @@ -68,18 +70,20 @@ class RegistrationService $newUser->socialAccounts()->save($socialAccount); } + Activity::add(ActivityType::AUTH_REGISTER, $socialAccount ?? $newUser); + // Start email confirmation flow if required if ($this->emailConfirmationService->confirmationRequired() && !$emailConfirmed) { $newUser->save(); - $message = ''; try { $this->emailConfirmationService->sendConfirmation($newUser); + session()->flash('sent-email-confirmation', true); } catch (Exception $e) { $message = trans('auth.email_confirm_send_error'); + throw new UserRegistrationException($message, '/register/confirm'); } - throw new UserRegistrationException($message, '/register/confirm'); } return $newUser; @@ -106,13 +110,4 @@ class RegistrationService } } - /** - * Alias to the UserRepo method of the same name. - * Attaches the default system role, if configured, to the given user. - */ - public function attachDefaultRole(User $user): void - { - $this->userRepo->attachDefaultRole($user); - } - } \ No newline at end of file