fix: add authorization checks for environment and project views
This commit is contained in:
parent
5f33ad74b5
commit
ce134cb8b1
3 changed files with 15 additions and 19 deletions
|
|
@ -60,6 +60,7 @@ public function mount()
|
||||||
|
|
||||||
public function switch()
|
public function switch()
|
||||||
{
|
{
|
||||||
|
$this->authorize('view', $this->environment);
|
||||||
$this->view = $this->view === 'normal' ? 'dev' : 'normal';
|
$this->view = $this->view === 'normal' ? 'dev' : 'normal';
|
||||||
$this->getDevView();
|
$this->getDevView();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,7 @@ public function mount()
|
||||||
|
|
||||||
public function switch()
|
public function switch()
|
||||||
{
|
{
|
||||||
|
$this->authorize('view', $this->project);
|
||||||
$this->view = $this->view === 'normal' ? 'dev' : 'normal';
|
$this->view = $this->view === 'normal' ? 'dev' : 'normal';
|
||||||
$this->getDevView();
|
$this->getDevView();
|
||||||
}
|
}
|
||||||
|
|
@ -97,25 +98,19 @@ private function handleBulkSubmit()
|
||||||
{
|
{
|
||||||
$variables = parseEnvFormatToArray($this->variables);
|
$variables = parseEnvFormatToArray($this->variables);
|
||||||
|
|
||||||
DB::transaction(function () use ($variables) {
|
$changesMade = DB::transaction(function () use ($variables) {
|
||||||
$changesMade = false;
|
|
||||||
|
|
||||||
// Delete removed variables
|
// Delete removed variables
|
||||||
$deletedCount = $this->deleteRemovedVariables($variables);
|
$deletedCount = $this->deleteRemovedVariables($variables);
|
||||||
if ($deletedCount > 0) {
|
|
||||||
$changesMade = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update or create variables
|
// Update or create variables
|
||||||
$updatedCount = $this->updateOrCreateVariables($variables);
|
$updatedCount = $this->updateOrCreateVariables($variables);
|
||||||
if ($updatedCount > 0) {
|
|
||||||
$changesMade = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($changesMade) {
|
return $deletedCount > 0 || $updatedCount > 0;
|
||||||
$this->dispatch('success', 'Environment variables updated.');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if ($changesMade) {
|
||||||
|
$this->dispatch('success', 'Environment variables updated.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function deleteRemovedVariables($variables)
|
private function deleteRemovedVariables($variables)
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ public function mount()
|
||||||
|
|
||||||
public function switch()
|
public function switch()
|
||||||
{
|
{
|
||||||
|
$this->authorize('view', $this->team);
|
||||||
$this->view = $this->view === 'normal' ? 'dev' : 'normal';
|
$this->view = $this->view === 'normal' ? 'dev' : 'normal';
|
||||||
$this->getDevView();
|
$this->getDevView();
|
||||||
}
|
}
|
||||||
|
|
@ -90,10 +91,9 @@ public function submit()
|
||||||
private function handleBulkSubmit()
|
private function handleBulkSubmit()
|
||||||
{
|
{
|
||||||
$variables = parseEnvFormatToArray($this->variables);
|
$variables = parseEnvFormatToArray($this->variables);
|
||||||
|
$changesMade = false;
|
||||||
|
|
||||||
DB::transaction(function () use ($variables) {
|
DB::transaction(function () use ($variables, &$changesMade) {
|
||||||
$changesMade = false;
|
|
||||||
|
|
||||||
// Delete removed variables
|
// Delete removed variables
|
||||||
$deletedCount = $this->deleteRemovedVariables($variables);
|
$deletedCount = $this->deleteRemovedVariables($variables);
|
||||||
if ($deletedCount > 0) {
|
if ($deletedCount > 0) {
|
||||||
|
|
@ -105,11 +105,11 @@ private function handleBulkSubmit()
|
||||||
if ($updatedCount > 0) {
|
if ($updatedCount > 0) {
|
||||||
$changesMade = true;
|
$changesMade = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($changesMade) {
|
|
||||||
$this->dispatch('success', 'Environment variables updated.');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if ($changesMade) {
|
||||||
|
$this->dispatch('success', 'Environment variables updated.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function deleteRemovedVariables($variables)
|
private function deleteRemovedVariables($variables)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue