From 68ad1c429490eb53046ddfe86f77e684e4bb1680 Mon Sep 17 00:00:00 2001 From: Chidi Ekuma Date: Sat, 9 Mar 2024 23:22:43 +0000 Subject: [PATCH] Refactor user creation logic in Schools::UsersController*** --- app/controllers/schools/users_controller.rb | 26 ++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/app/controllers/schools/users_controller.rb b/app/controllers/schools/users_controller.rb index 77f2ceb0f9..43afa5ed5c 100644 --- a/app/controllers/schools/users_controller.rb +++ b/app/controllers/schools/users_controller.rb @@ -11,21 +11,21 @@ def new end def create - @user_invite = DFESignInAPI::UserInvite.new(user_params) - redirect_to root_path + # @user_invite = DFESignInAPI::UserInvite.new(user_params) + # redirect_to root_path # @user_invite.organisation_id = DFESignInAPI::Organisation.new(current_user.sub, # current_school.urn).current_organisation_id - # if params[:confirmed] == 'true' - # if @user_invite.valid? - # # @user_invite.invite_user - # redirect_to schools_users_path, notice: "#{@user_invite.email} has been added." - # else - # render :new - # end - # else - # render :show - # end + if params[:confirmed] == 'true' + if @user_invite.valid? + # @user_invite.invite_user + redirect_to schools_users_path, notice: "#{@user_invite.email} has been added." + else + render :new + end + else + render :show + end end def show @@ -36,7 +36,7 @@ def show private def user_params - params.require(:user).permit(:email, :firstname, :lastname, :organisation_id) + params.require(:user_invite).permit(:email, :firstname, :lastname, :organisation_id) end end end