Skip to content

Commit

Permalink
Refactor user creation logic in Schools::UsersController***
Browse files Browse the repository at this point in the history
  • Loading branch information
ekumachidi committed Mar 9, 2024
1 parent 74213b1 commit 68ad1c4
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions app/controllers/schools/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 68ad1c4

Please sign in to comment.