mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-18 02:12:30 +08:00
Users: Improved user response for failed invite sending
Added specific handling to show relevant error message when user creation fails due to invite sending errors, while also returning user to the form with previous input. Includes test to cover. For #5195
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
namespace BookStack\Users\Controllers;
|
||||
|
||||
use BookStack\Access\SocialDriverManager;
|
||||
use BookStack\Access\UserInviteException;
|
||||
use BookStack\Exceptions\ImageUploadException;
|
||||
use BookStack\Exceptions\UserUpdateException;
|
||||
use BookStack\Http\Controller;
|
||||
@ -14,6 +15,7 @@ use BookStack\Util\SimpleListOptions;
|
||||
use Exception;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Validation\Rules\Password;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
@ -91,9 +93,16 @@ class UserController extends Controller
|
||||
|
||||
$validated = $this->validate($request, array_filter($validationRules));
|
||||
|
||||
DB::transaction(function () use ($validated, $sendInvite) {
|
||||
$this->userRepo->create($validated, $sendInvite);
|
||||
});
|
||||
try {
|
||||
DB::transaction(function () use ($validated, $sendInvite) {
|
||||
$this->userRepo->create($validated, $sendInvite);
|
||||
dd('post-create');
|
||||
});
|
||||
} catch (UserInviteException $e) {
|
||||
Log::error("Failed to send user invite with error: {$e->getMessage()}");
|
||||
$this->showErrorNotification(trans('errors.users_could_not_send_invite'));
|
||||
return redirect('/settings/users/create')->withInput();
|
||||
}
|
||||
|
||||
return redirect('/settings/users');
|
||||
}
|
||||
|
Reference in New Issue
Block a user