Skip to content

Commit 7a99dcf

Browse files
author
Pascal Meunier
committed
remove people from location_us group if they login from elsewhere or if they are in the d1_nation group. The purdue group will supersede the location_us group through unix ACLs that will allow access to people in the purdue group for things that are restricted to people in the US
1 parent f1001d2 commit 7a99dcf

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

core/plugins/user/us/us.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@ public function onUserLogin($user, $options = array())
2929
{
3030
$ip = $_SERVER['REMOTE_ADDR'];
3131

32+
$d1 = \Hubzero\User\Group::getInstance('d1_nation');
33+
34+
if (is_object($d1) && in_array(User::get('id'), $d1->get('members')))
35+
{
36+
Log::debug('[' . User::get('username') . '] is a member of [d1_nation], removing from group [location_us].');
37+
38+
$group = \Hubzero\User\Group::getInstance('location_us');
39+
40+
if (is_object($group))
41+
{
42+
$group->remove('members', array(User::get('id')));
43+
$group->update();
44+
}
45+
46+
return;
47+
}
48+
3249
$gdb = \Hubzero\Geocode\Geocode::getGeoDBO();
3350

3451
if (!$gdb)
@@ -62,7 +79,15 @@ public function onUserLogin($user, $options = array())
6279
}
6380
else
6481
{
65-
Log::debug($ip . ' is not a US address, leaving [' . User::get('username') . '] membership to group [location_us] unchanged.');
82+
Log::debug($ip . ' is not a US address, removing [' . User::get('username') . '] from group [location_us].');
83+
84+
$group = \Hubzero\User\Group::getInstance('location_us');
85+
86+
if (is_object($group))
87+
{
88+
$group->remove('members', array(User::get('id')));
89+
$group->update();
90+
}
6691
}
6792
}
6893

0 commit comments

Comments
 (0)