I had a weird request. They want me to make the site require login before you can view the site.
What would be the best way to accomplish this? Is there a way to make the site redirect to a Login page if they are not logged in?
Thanks,
Eric
You can do it with permissions, but I think this would be simpler. Just put a snippet with this code at the top of every template:
<?php
/* Unauthorized snippet */
if (! $modx->user->hasSessionContext($modx->context->get('key'))) {
$modx->sendUnauthorizedPage();
} else {
return '';
}
You can define the unauthorized page in System Settings. It could be a login page, the home page, or something else.