Add authorization rule for create user by unsigned user
Add authorization to failed user save path cause it was complaining that no authorization was performed in that path.
This commit is contained in:
parent
dcb98c49f9
commit
e851c0b4ff
3 changed files with 3 additions and 1 deletions
|
|
@ -34,6 +34,7 @@ class ProposalController < ApplicationController
|
||||||
# If user is not signed in then first create new user and then sign them in
|
# If user is not signed in then first create new user and then sign them in
|
||||||
unless current_user
|
unless current_user
|
||||||
@user = User.new(user_params)
|
@user = User.new(user_params)
|
||||||
|
authorize! :create, @user
|
||||||
if @user.save
|
if @user.save
|
||||||
sign_in(@user)
|
sign_in(@user)
|
||||||
else
|
else
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ class Ability
|
||||||
|
|
||||||
# can view Commercials of confirmed Events
|
# can view Commercials of confirmed Events
|
||||||
can :show, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(state: 'confirmed').pluck(:id)
|
can :show, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(state: 'confirmed').pluck(:id)
|
||||||
can :show, User
|
can [:show, :create], User
|
||||||
unless CONFIG['authentication']['ichain']['enabled']
|
unless CONFIG['authentication']['ichain']['enabled']
|
||||||
can [:show, :create], Registration do |registration|
|
can [:show, :create], Registration do |registration|
|
||||||
registration.new_record?
|
registration.new_record?
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ describe 'User' do
|
||||||
it{ should_not be_able_to(:show, commercial_event_unconfirmed)}
|
it{ should_not be_able_to(:show, commercial_event_unconfirmed)}
|
||||||
|
|
||||||
it{ should be_able_to(:show, User)}
|
it{ should be_able_to(:show, User)}
|
||||||
|
it{ should be_able_to(:create, User)}
|
||||||
|
|
||||||
it{ should be_able_to(:create, Registration)}
|
it{ should be_able_to(:create, Registration)}
|
||||||
it{ should be_able_to(:show, Registration.new)}
|
it{ should be_able_to(:show, Registration.new)}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue