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