Make membership required for create_user_by_membership

This commit is contained in:
Shinya Maeda 2017-06-28 22:04:49 +09:00
parent af129038e0
commit d9d5600711

View file

@ -25,6 +25,8 @@ module AccessMatchersForController
user = role
sign_in(user)
when *Gitlab::Access.sym_options_with_owner.keys # owner, master, developer, reporter, guest
raise ArgumentError, "cannot emulate #{role} without membership parent" unless membership
user = create_user_by_membership(role, membership)
sign_in(user)
else
@ -34,9 +36,7 @@ module AccessMatchersForController
user
end
def create_user_by_membership(role, membership = nil)
raise ArgumentError, "cannot emulate #{role} without membership parent" unless membership
def create_user_by_membership(role, membership)
if role == :owner && membership.owner
user = membership.owner
else