Skip to content

Commit 794a615

Browse files
committed
restric access to user emails
1 parent af1ea04 commit 794a615

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

app/graphql/types/user_type.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class UserType < Types::BaseObject
99
field :avatar_path, String, null: true, description: 'The avatar if present of the user'
1010

1111
field :admin, Boolean, null: false, description: 'Global admin status of the user'
12-
field :email, String, null: false, description: 'Email of the user'
12+
field :email, String, null: false, description: 'Email of the user', authorize: :read_email
1313
field :email_verified_at, Types::TimeType, null: true, description: 'Email verification date of the user if present'
1414
field :firstname, String, null: true, description: 'Firstname of the user'
1515
field :lastname, String, null: true, description: 'Lastname of the user'

app/policies/user_policy.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class UserPolicy < BasePolicy
1010
enable :update_user
1111
enable :read_user_identity
1212
enable :update_attachment_avatar
13+
enable :read_email
1314
end
1415

1516
rule { user_is_self }.policy do
@@ -19,5 +20,6 @@ class UserPolicy < BasePolicy
1920
enable :update_attachment_avatar
2021
enable :verify_email
2122
enable :send_verification_email
23+
enable :read_email
2224
end
2325
end

tooling/graphql/types/package-lock.json

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)