Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #258 from sharetribe/fix-incorrect-authorization-c…
…heck Fix incorrect authorization check
- Loading branch information
Showing
7 changed files
with
145 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
class IntApi::Listing::BlockedDatesController < ApplicationController | ||
respond_to :json | ||
|
||
before_action :ensure_current_user_is_listing_author | ||
|
||
def index | ||
respond_with listing.blocked_dates.in_period(params[:start_on], params[:end_on]), location: nil | ||
end | ||
|
||
private | ||
|
||
def listing | ||
@listing ||= Listing.find(params[:listing_id]) | ||
@listing ||= @current_community.listings.find(params[:listing_id]) | ||
end | ||
|
||
def ensure_current_user_is_listing_author | ||
return true if !listing.deleted? && (current_user?(listing.author) || @current_user.has_admin_rights?(@current_community)) | ||
|
||
head(:forbidden) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,21 @@ | ||
class IntApi::Listing::BookingsController < ApplicationController | ||
respond_to :json | ||
|
||
before_action :ensure_current_user_is_listing_author | ||
|
||
def index | ||
respond_with listing.booked_dates(params[:start_on].to_date, params[:end_on].to_date).sort, location: nil | ||
end | ||
|
||
private | ||
|
||
def listing | ||
@listing ||= Listing.find(params[:listing_id]) | ||
@listing ||= @current_community.listings.find(params[:listing_id]) | ||
end | ||
|
||
def ensure_current_user_is_listing_author | ||
return true if !listing.deleted? && (current_user?(listing.author) || @current_user.has_admin_rights?(@current_community)) | ||
|
||
head(:forbidden) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters