add back the ZM_OPT_USE_AUTH test for being logged in in AppController

This commit is contained in:
Isaac Connor
2018-07-24 12:01:40 -04:00
parent 08d3f98e5e
commit 3255a2829f

View File

@@ -75,18 +75,20 @@ class AppController extends Controller {
global $user;
$user = $this->Session->read('user');
// We need to reject methods that are not authenticated
// besides login and logout
if ( strcasecmp($this->params->action, 'login') &&
strcasecmp($this->params->action, 'logout')) {
if ( !$this->Session->read('user.Username') ) {
throw new UnauthorizedException(__('Not Authenticated'));
return;
} else if ( !$this->Session->read('user.Enabled') ) {
throw new UnauthorizedException(__('User is not enabled'));
return;
}
} # end if ! login or logout
if ( ZM_OPT_USE_AUTH ) {
// We need to reject methods that are not authenticated
// besides login and logout
if ( strcasecmp($this->params->action, 'login') &&
strcasecmp($this->params->action, 'logout')) {
if ( !( $user and $user['Username'] ) ) {
throw new UnauthorizedException(__('Not Authenticated'));
return;
} else if ( !( $user and $user['Enabled'] ) ) {
throw new UnauthorizedException(__('User is not enabled'));
return;
}
} # end if ! login or logout
} # end if ZM_OPT_AUTH
} # end function beforeFilter()
}