Now if your Contao website already has members you obviously do not want them all to have access to that other system (or I assume that is not always a good thing). You can also check for member groups of the logged in user to see if they have access.
To do this you need to add a member group like "ozd". Members that should have access get assigned to this member group.
Secondly at some point in your code you need to check if the user is a member of that group. I've done that as follows, but I'm not sure the code is still current as it was written for a Contao version of about 18 months old.
Code:
function contaoLookup($memberGroup) {
if ( isset($_COOKIE['FE_USER_AUTH']) ) {
$storage = $this->getDbStorage();
// Do Contao verification
$query = "SELECT `tl_member`.`groups` "
. "FROM ( `tl_session` "
. " LEFT JOIN `tl_member` "
. " ON `tl_session`.`pid` = `tl_member`.`id` ) "
. "WHERE `tl_session`.`hash` = '{$_COOKIE['FE_USER_AUTH']}' "
. "AND `tl_session`.`name` = 'FE_USER_AUTH' ";
$storage->query_first($query);
if ( $storage->has_rows() ) {
$groups = unserialize($storage->f('groups'));
$groups = "( `tl_member_group`.`id` = " . implode(" OR `tl_member_group`.`id` = ", $groups) . " ) ";
$query = "SELECT `id` "
. "FROM `tl_member_group` "
. "WHERE `tl_member_group`.`name` = '" . $memberGroup . "' "
. "AND {$groups} ";
$storage->query($query);
if ( $storage->has_rows() ) {
return true;
}
}
}
return false;
}
You'd need to convert that to whatever framework or code the custom php code is using.
Bookmarks