users can view their own spending proposals
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
class SpendingProposalsController < ApplicationController
|
||||
include FeatureFlags
|
||||
|
||||
before_action :authenticate_user!, except: [:index]
|
||||
before_action :verify_valuator, only: [:show]
|
||||
|
||||
load_and_authorize_resource
|
||||
|
||||
before_action :authenticate_user!, except: [:index]
|
||||
before_action :verify_access, only: [:show]
|
||||
|
||||
feature_flag :spending_proposals
|
||||
|
||||
def index
|
||||
@@ -20,7 +20,7 @@ class SpendingProposalsController < ApplicationController
|
||||
@spending_proposal.author = current_user
|
||||
|
||||
if @spending_proposal.save_with_captcha
|
||||
redirect_to spending_proposals_path, notice: t("flash.actions.create.spending_proposal")
|
||||
redirect_to @spending_proposal, notice: t("flash.actions.create.spending_proposal")
|
||||
else
|
||||
render :new
|
||||
end
|
||||
@@ -32,8 +32,8 @@ class SpendingProposalsController < ApplicationController
|
||||
params.require(:spending_proposal).permit(:title, :description, :external_url, :geozone_id, :association_name, :terms_of_service, :captcha, :captcha_key)
|
||||
end
|
||||
|
||||
def verify_valuator
|
||||
raise CanCan::AccessDenied unless current_user.try(:valuator?) || current_user.try(:administrator?)
|
||||
def verify_access
|
||||
raise CanCan::AccessDenied unless current_user.try(:valuator?) || current_user.try(:administrator?) || @spending_proposal.author == current_user
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user