forbid removed users from joining the group again
This commit is contained in:
parent
b9641b41e7
commit
6e37a72ed6
|
@ -24,6 +24,7 @@ class GroupPolicy < ApplicationPolicy
|
|||
def join?
|
||||
check_archive!
|
||||
raise GabSocial::ValidationError, "User is already a member of this group." if is_member?
|
||||
raise GabSocial::ValidationError, "Account is removed from this group." if is_removed?
|
||||
|
||||
return true
|
||||
end
|
||||
|
@ -56,6 +57,10 @@ class GroupPolicy < ApplicationPolicy
|
|||
|
||||
private
|
||||
|
||||
def is_removed?
|
||||
record.group_removed_accounts.where(account_id: current_account.id).exists?
|
||||
end
|
||||
|
||||
def is_member?
|
||||
record.group_accounts.where(account_id: current_account.id).exists?
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue