Skip to content

Commit

Permalink
Only project owners can invite members
Browse files Browse the repository at this point in the history
  • Loading branch information
canvasowl committed Aug 20, 2016
1 parent a42ef93 commit 665a6f9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/Http/Controllers/ProjectsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ public function invite($project_id, $email){
}

$project_name = Project::find($project_id)->pluck('name');
$owner_id = Project::find($project_id)->pluck('user_id');
$project_url = url() . '/projects/'.$project_id;
$invited_user = User::whereEmail($email)->get();
$invited_user = User::whereEmail($email)->get();

if( count($invited_user) == 0 ){
return $this->setStatusCode(406)->makeResponse('That user does not have an account.');
Expand All @@ -153,6 +154,9 @@ public function invite($project_id, $email){
return $this->setStatusCode(406)->makeResponse('A user with that email has already been invited.');
}

if(Auth::id() != $owner_id){
return $this->setStatusCode(406)->makeResponse('Only the project owner can invite a user.');
}
// Save the relationship between user and project.
$pu = new Projectuser();
$pu->project_id = $project_id;
Expand Down

0 comments on commit 665a6f9

Please sign in to comment.