Merge pull request #436 from ZmagoD/zd_SCI_922

fixed user without permissions bug [fixes SCI-922]
This commit is contained in:
Zmago Devetak 2017-01-23 17:25:07 +01:00 committed by GitHub
commit 674999f987
2 changed files with 9 additions and 1 deletions

View file

@ -118,7 +118,10 @@ module ApplicationHelper
match = el.match(sa_user)
user = User.find_by_id(match[2].base62_decode)
organization ||= current_organization
if user && organization
if user &&
organization &&
UserOrganization.user_in_organization(user, organization).any?
user_org = user
.user_organizations
.where('user_organizations.organization_id = ?',

View file

@ -30,6 +30,11 @@ class UserOrganization < ActiveRecord::Base
end
end
# returns user_organizations where the user is in org
def self.user_in_organization(user, organization)
where(user: user, organization: organization)
end
def destroy(new_owner)
# If any project of the organization has the sole owner and that
# owner is the user to be removed from the organization, then we must