Skip to content

Commit e68bd82

Browse files
authored
Merge pull request #668 from code0-tech/663-restrict-access-to-user-emails
restric access to user emails
2 parents 6a6c863 + 7e6ef7a commit e68bd82

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

app/graphql/types/user_type.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ 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'
13-
field :email_verified_at, Types::TimeType, null: true, description: 'Email verification date of the user if present'
12+
field :email, String, null: false, description: 'Email of the user', authorize: :read_email
13+
field :email_verified_at, Types::TimeType, null: true,
14+
description: 'Email verification date of the user if present',
15+
authorize: :read_email
1416
field :firstname, String, null: true, description: 'Firstname of the user'
1517
field :lastname, String, null: true, description: 'Lastname of the user'
1618
field :username, String, null: false, description: 'Username 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)