diff --git a/app/controllers/schools/users_controller.rb b/app/controllers/schools/users_controller.rb index 2609d3f2f..5515cbd2f 100644 --- a/app/controllers/schools/users_controller.rb +++ b/app/controllers/schools/users_controller.rb @@ -1,7 +1,7 @@ module Schools class UsersController < BaseController def index - @users = DFESignInAPI::OrganisationUsers.new(current_user.sub, current_school.urn).users + @users = DFESignInAPI::OrganisationUsers.new(current_user.sub, current_school.urn).users_as_invite_objects @dfe_sign_in_manage_users_url = Rails.application.config.x.dfe_sign_in_manage_users_url.presence end diff --git a/app/services/schools/dfe_sign_in_api/organisation_users.rb b/app/services/schools/dfe_sign_in_api/organisation_users.rb index e256d33d5..dc71a14b3 100644 --- a/app/services/schools/dfe_sign_in_api/organisation_users.rb +++ b/app/services/schools/dfe_sign_in_api/organisation_users.rb @@ -14,6 +14,20 @@ def ukprn def users response&.fetch('users', nil) + # users_as_invite_objects + end + + def users_as_invite_objects + return [] if users.blank? + + users.map do |user_data| + Schools::DFESignInAPI::UserInvite.new( + email: user_data['email'], + firstname: user_data['firstName'], + lastname: user_data['lastName'], + organisation_id: current_school_urn + ) + end end private diff --git a/app/views/schools/users/index.html.erb b/app/views/schools/users/index.html.erb index abe596e39..08b124f14 100644 --- a/app/views/schools/users/index.html.erb +++ b/app/views/schools/users/index.html.erb @@ -28,7 +28,9 @@ <% if @users.any? %>
<%= "#{user['firstName']} #{user['lastName']}" %> | -<%= user['email'] %> | +<%= "#{user.firstname} #{user.lastname}" %> | +<%= user.email %> |