Commit ffcabe1

mo <mo.khan@gmail.com>
2018-01-14 19:10:12
move mapping to scim schema to controller.
1 parent 854556c
Changed files (3)
app
controllers
models
config
initializers
app/controllers/scim/v2/users_controller.rb
@@ -8,7 +8,7 @@ module Scim
         )
         response.headers['Content-Type'] = 'application/scim+json'
         response.headers['Location'] = scim_v2_users_url(@user)
-        render json: @user.to_scim(self), status: :created
+        render json: map_from(@user), status: :created
       end
 
       private
@@ -19,6 +19,17 @@ module Scim
       def user_params
         params.permit(:schemas, :userName)
       end
+
+      def map_from(user)
+        Scim::Shady::User.build do |x|
+          x.id = user.uuid
+          x.username = user.email
+          x.created_at = user.created_at
+          x.updated_at = user.updated_at
+          x.location = scim_v2_users_url(self)
+          x.version = user.lock_version
+        end
+      end
     end
   end
 end
app/models/user.rb
@@ -14,17 +14,6 @@ class User < ApplicationRecord
     request.trusted? ? trusted_attributes : {}
   end
 
-  def to_scim(url_helpers)
-    Scim::Shady::User.build do |x|
-      x.id = uuid
-      x.username = email
-      x.created_at = created_at
-      x.updated_at = updated_at
-      x.location = url_helpers.scim_v2_users_url(self)
-      x.version = lock_version
-    end
-  end
-
   def self.login(email, password)
     return if email.blank? || password.blank?
 
config/initializers/saml_kit.rb
@@ -1,5 +1,3 @@
-$next_key_pair_index = 0
-
 class OnDemandRegistry < SimpleDelegator
   def metadata_for(entity_id)
     found = __getobj__.metadata_for(entity_id)