Skip to content
This repository has been archived by the owner on Jul 23, 2024. It is now read-only.

Commit

Permalink
move AdminDetailedUserSerializer additions out of plugin.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoMcA committed Aug 7, 2018
1 parent 6498054 commit 64307f3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 2 additions & 0 deletions config/initializers/patch_admin_detailed_user_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
AdminDetailedUserSerializer.include MozillaIAM::AdminDetailedUserSerializerExtensions
AdminDetailedUserSerializer.attributes :mozilla_iam
1 change: 1 addition & 0 deletions lib/mozilla_iam.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require_relative 'mozilla_iam/engine'

require_relative 'mozilla_iam/admin_detailed_user_serializer_extensions'
require_relative 'mozilla_iam/api'
require_relative 'mozilla_iam/person_api'
require_relative 'mozilla_iam/management_api'
Expand Down
13 changes: 13 additions & 0 deletions lib/mozilla_iam/admin_detailed_user_serializer_extensions.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module MozillaIAM
module AdminDetailedUserSerializerExtensions

def mozilla_iam
object.custom_fields.select do |k, v|
k.start_with?('mozilla_iam')
end.map do |k, v|
[k.sub('mozilla_iam_', ''), v]
end.to_h
end

end
end
12 changes: 0 additions & 12 deletions plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,3 @@
message: 'Log In / Sign Up',
authenticator: MozillaIAM::Authenticator.new('auth0', trusted: true),
full_screen_login: true)

after_initialize do

add_to_serializer(:AdminDetailedUser, :mozilla_iam, false) do
object.custom_fields.select do |k, v|
k.start_with?('mozilla_iam')
end.map do |k, v|
[k.sub('mozilla_iam_', ''), v]
end.to_h
end

end

0 comments on commit 64307f3

Please sign in to comment.