Skip to content

Commit b28fd55

Browse files
committed
fix: update authorization logic in saveAs to handle new projects
- Added conditional check to authorize `create` for new projects and `update` for existing ones.
1 parent 546838c commit b28fd55

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/Livewire/Project/EditProject.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,11 @@ public function removePost(int $index): void
170170
*/
171171
public function saveAs($stateName)
172172
{
173-
$this->authorize('update', $this->getProject());
173+
if($this->isNew){
174+
$this->authorize('create', Project::class);
175+
}else{
176+
$this->authorize('update', $this->getProject());
177+
}
174178
$state = ProjectState::make($stateName, $this->getProject() ?? new Project);
175179
$validator = Validator::make(
176180
$this->getValues() + [

0 commit comments

Comments
 (0)