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:
Aditya Prakash 2016-03-24 17:42:00 +05:30
parent dcb98c49f9
commit e851c0b4ff
3 changed files with 3 additions and 1 deletions

View file

@ -34,6 +34,7 @@ class ProposalController < ApplicationController
# If user is not signed in then first create new user and then sign them in
unless current_user
@user = User.new(user_params)
authorize! :create, @user
if @user.save
sign_in(@user)
else

View file

@ -44,7 +44,7 @@ class Ability
# can view Commercials of confirmed Events
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']
can [:show, :create], Registration do |registration|
registration.new_record?

View file

@ -56,6 +56,7 @@ describe 'User' do
it{ should_not be_able_to(:show, commercial_event_unconfirmed)}
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(:show, Registration.new)}