Automattic / WP-Job-Manager

Manage job listings from the WordPress admin panel, and allow users to post jobs directly to your site.

Home Page:https://wpjobmanager.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Preview of a listing can be viewed and edited by anybody

davoraltman opened this issue · comments

What I Expected To Happen

The preview of a listing on the frontend should be restricted to the user who created it.

What Happened Instead

However, it can be viewed and edited by anyone.

Steps to Reproduce the Bug

Create a new listing and click on preview. Copy the URL of that page. Open page source and look for job_id and its value. Append ?job_id=xxxx (xxxx being the number of the job_id from the page source) and visit the URL in an incognito window/another browser. You'll be able to view and edit the preview.

commented

It's due to this line setting the protected $this->job_id from $_REQUEST['job_id'] without any other verifications

https://github.com/Automattic/WP-Job-Manager/blob/master/includes/forms/class-wp-job-manager-form-submit-job.php#L60

commented

Specifically setting the value to 0 may cause issues down the line because now you're requiring the cookie to be set .... and there may be instances where the cookie isn't going to be set, and probably cause issues.

Nobody replied to my comment (which seems to be common) so there was no discussion about this ... but if anything it should be checking with the built in function to see if user can edit the listing, and THEN set it to 0 if they can't .... just like it does when editing a listing

@donnchawp can you take a look at this when you have time? Cheers :)
@tripflex Thanks!

@tripflex - thanks for checking that. You're right, that it should use the built in function to check if the user has authority to edit the job.

I merged #771 from @tripflex which fixes the problem by using the job_manager_user_can_edit_job() function. Thanks!