Bypass login by IP address

265 Views Asked by At

I have a client that wants to use Concrete5.7 for an employee portal. If they are in the building, he does not want them to have to log in to view the site. However, if they are not in the building, he wants them to be able to access the site via a login. The building has a static IP address. Is there a way to over-ride the login or automatically use a specific credential if the user is accessing the site from a specific IP address?

1

There are 1 best solutions below

2
biplob On

You can use the concrete5 Application Events

For example-

Events::addListener('on_before_render', function($event) {
    $clientIp = Request::getInstance()->getClientIp();
    if ($clientIp === YOUR_STATIC_IP) {
        $service = Core::make(\Concrete\Core\User\Login\LoginService::class);
        $service->loginByUserID(THE_ID_YOU_WANT_TO_USE);
    }
});

This is just an example. Please follow the recommended convention on concrete5 documentation.