Commit 37e776d2 authored by GitLab Release Tools Bot's avatar GitLab Release Tools Bot

Merge branch 'security-enforce-group-member-2fa' into 'master'

Update user 2fa when accepting group invite

See merge request gitlab-org/security/gitlab!169
parents 9919924f 38d2bf40
......@@ -66,6 +66,7 @@ class GroupMember < Member
def after_accept_invite
notification_service.accept_group_invite(self)
update_two_factor_requirement
super
end
......
---
title: Update user 2fa when accepting a group invite
merge_request:
author:
type: security
......@@ -65,10 +65,10 @@ describe GroupMember do
end
describe '#update_two_factor_requirement' do
let(:user) { build :user }
let(:group_member) { build :group_member, user: user }
it 'is called after creation and deletion' do
user = build :user
group_member = build :group_member, user: user
expect(user).to receive(:update_two_factor_requirement)
group_member.save
......@@ -79,6 +79,21 @@ describe GroupMember do
end
end
describe '#after_accept_invite' do
it 'calls #update_two_factor_requirement' do
email = 'foo@email.com'
user = build(:user, email: email)
group = create(:group, require_two_factor_authentication: true)
group_member = create(:group_member, group: group, invite_token: '1234', invite_email: email)
expect(user).to receive(:require_two_factor_authentication_from_group).and_call_original
group_member.accept_invite!(user)
expect(user.require_two_factor_authentication_from_group).to be_truthy
end
end
context 'access levels' do
context 'with parent group' do
it_behaves_like 'inherited access level as a member of entity' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment