Extract user creation method if not signed in
related to openSUSE/osem#597 Signed-off-by: Carlos Coelho <carlos@pencillabs.com>
This commit is contained in:
parent
3dc7aaf4ea
commit
b58a00b321
1 changed files with 14 additions and 10 deletions
|
|
@ -26,16 +26,7 @@ class ProposalController < ApplicationController
|
||||||
def create
|
def create
|
||||||
@url = conference_program_proposal_index_path(@conference.short_title)
|
@url = conference_program_proposal_index_path(@conference.short_title)
|
||||||
|
|
||||||
unless current_user
|
create_user_if_not_signed_in
|
||||||
@user = User.new(user_params)
|
|
||||||
if @user.save
|
|
||||||
sign_in(@user)
|
|
||||||
else
|
|
||||||
flash[:error] = "Could not save user: #{@user.errors.full_messages.join(', ')}"
|
|
||||||
render action: 'new'
|
|
||||||
return
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
params[:event].delete :user
|
params[:event].delete :user
|
||||||
|
|
||||||
|
|
@ -146,6 +137,19 @@ class ProposalController < ApplicationController
|
||||||
def user_params
|
def user_params
|
||||||
params.require(:user).permit(:email, :password, :password_confirmation, :username)
|
params.require(:user).permit(:email, :password, :password_confirmation, :username)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_user_if_not_signed_in
|
||||||
|
unless current_user
|
||||||
|
@user = User.new(user_params)
|
||||||
|
if @user.save
|
||||||
|
sign_in(@user)
|
||||||
|
else
|
||||||
|
flash[:error] = "Could not save user: #{@user.errors.full_messages.join(', ')}"
|
||||||
|
render action: 'new'
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# FIXME: Introduce strong_parameters pronto!
|
# FIXME: Introduce strong_parameters pronto!
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue