Skip to content

Commit

Permalink
move email from an explicit auth error to hidden
Browse files Browse the repository at this point in the history
  • Loading branch information
acoffman committed Oct 29, 2024
1 parent 19dd35e commit aec14ad
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions server/app/graphql/types/entities/user_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class UserType < Types::BaseObject
field :most_recent_activity_timestamp, GraphQL::Types::ISO8601DateTime, null: true
field :most_recent_organization_id, Int, null: true
field :ranks, Types::Entities::RanksType, null: false
field :email, String, null: true

profile_image_sizes = [256, 128, 64, 32, 18, 12]
field :profile_image_path, String, null: true do
Expand All @@ -33,12 +34,6 @@ class UserType < Types::BaseObject
}
end

field :email, String, null: true do
def authorized?(object, args, context)
object.id == context[:current_user]&.id
end
end

field :notifications, Types::Entities::NotificationType.connection_type, null: true do
description 'Filterable list of notifications for the logged in user.'
type_desc = 'Filter the response to include only notifications of a certain type (ex: mentions).'
Expand All @@ -55,6 +50,15 @@ def authorized?(object, args, context)
end
end

def email
#You can only fetch your own email
if object.id == context[:current_user]&.id
object.email
else
nil
end
end

def organizations
Loaders::AssociationLoader.for(User, :organizations).load(object)
end
Expand Down

0 comments on commit aec14ad

Please sign in to comment.