Skip to content

Commit 43f070d

Browse files
Apply suggestions from code review
Co-authored-by: Niklas van Schrick <mc.taucher2003@gmail.com> Signed-off-by: Raphael Götz <52959657+raphael-goetz@users.noreply.github.com>
1 parent 02626cf commit 43f070d

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

app/policies/user_policy.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class UserPolicy < BasePolicy
44
condition(:user_is_self) { subject.id == user&.id }
55
condition(:user_is_admin) { user&.admin? || false }
6-
condition(:user_is_regular) { subject.regular? }
6+
condition(:subject_is_regular) { subject.regular? }
77
condition(:admin_status_visible) { ApplicationSetting.current[:admin_status_visible] }
88

99
rule { ~anonymous }.enable :read_user
@@ -13,11 +13,12 @@ class UserPolicy < BasePolicy
1313
enable :read_user_identity
1414
enable :update_attachment_avatar
1515
enable :read_email
16+
enable :delete_user
1617
enable :read_admin_status
1718
enable :read_mfa_status
1819
end
1920

20-
rule { user_is_admin & user_is_regular }.enable :delete_user
21+
rule { ~subject_is_regular }.prevent :delete_user
2122

2223
rule { admin_status_visible & ~anonymous }.enable :read_admin_status
2324

db/fixtures/02_users.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
u.password = SecureRandom.hex
77
u.admin = false
88
u.user_type = :ghost
9+
u.readme = 'This user will hold the activity of the users that have been deleted'
910
end

0 commit comments

Comments
 (0)