DEleted function in request and changed the way the controller uses it,
This commit is contained in:
@@ -13,6 +13,7 @@ use App\Models\User;
|
||||
use App\Models\UserGitConnection;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Inertia\Inertia;
|
||||
@@ -28,20 +29,21 @@ class ProjectRepositorySettingsController extends Controller
|
||||
|
||||
public function show(Request $request, Project $project): Response
|
||||
{
|
||||
$user = $request->user();
|
||||
abort_unless(
|
||||
$this->projectPermissionService->userCanManageProjectAccess($request->user(), $project),
|
||||
$this->projectPermissionService->userCanManageProjectAccess($user, $project),
|
||||
403,
|
||||
);
|
||||
|
||||
return Inertia::render('projects/settings/Repositories', [
|
||||
'availableRepositorySources' => $this->availableRepositorySources($request->user()),
|
||||
'availableRepositorySources' => $this->availableRepositorySources($user),
|
||||
'project' => $project,
|
||||
'repositoryConnections' => $project->repositoryConnections()
|
||||
->get()
|
||||
->map(fn (RepositoryConnection $repositoryConnection): array => [
|
||||
'base_url' => $repositoryConnection->base_url,
|
||||
'created_at' => $repositoryConnection->created_at?->toISOString(),
|
||||
'has_personal_access' => $this->hasPersonalAccess($request->user(), $repositoryConnection),
|
||||
'has_personal_access' => $this->hasPersonalAccess($user, $repositoryConnection),
|
||||
'id' => $repositoryConnection->id,
|
||||
'owner_name' => $repositoryConnection->owner_name,
|
||||
'project_id' => $repositoryConnection->project_id,
|
||||
@@ -62,15 +64,20 @@ class ProjectRepositorySettingsController extends Controller
|
||||
StoreRepositoryConnectionRequest $request,
|
||||
Project $project,
|
||||
): RedirectResponse {
|
||||
$user = $request->user();
|
||||
abort_unless(
|
||||
$this->projectPermissionService->userCanManageProjectAccess($request->user(), $project),
|
||||
$this->projectPermissionService->userCanManageProjectAccess($user, $project),
|
||||
403,
|
||||
);
|
||||
|
||||
$validated = $request->validated();
|
||||
$userGitConnectionId = Arr::get($validated, 'user_git_connection_id');
|
||||
$providerRepositoryId = Arr::get($validated, 'provider_repository_id');
|
||||
|
||||
$repositoryAttributes = $this->repositoryAttributesForSelection(
|
||||
$request->user(),
|
||||
$request->userGitConnectionId(),
|
||||
$request->providerRepositoryId(),
|
||||
$user,
|
||||
$userGitConnectionId,
|
||||
$providerRepositoryId,
|
||||
);
|
||||
|
||||
$this->ensureRepositoryConnectionIsUnique($project, $repositoryAttributes);
|
||||
@@ -86,15 +93,22 @@ class ProjectRepositorySettingsController extends Controller
|
||||
Project $project,
|
||||
RepositoryConnection $repositoryConnection,
|
||||
): RedirectResponse {
|
||||
$user = $request->user();
|
||||
|
||||
abort_unless(
|
||||
$this->projectPermissionService->userCanManageProjectAccess($request->user(), $project),
|
||||
$this->projectPermissionService->userCanManageProjectAccess($user, $project),
|
||||
403,
|
||||
);
|
||||
|
||||
|
||||
$validated = $request->validated();
|
||||
$userGitConnectionId = Arr::get($validated, 'user_git_connection_id');
|
||||
$providerRepositoryId = Arr::get($validated, 'provider_repository_id');
|
||||
|
||||
$repositoryAttributes = $this->repositoryAttributesForSelection(
|
||||
$request->user(),
|
||||
$request->userGitConnectionId(),
|
||||
$request->providerRepositoryId(),
|
||||
$user,
|
||||
$userGitConnectionId,
|
||||
$providerRepositoryId,
|
||||
);
|
||||
|
||||
$this->ensureRepositoryConnectionIsUnique(
|
||||
|
||||
Reference in New Issue
Block a user