public function show401($bLogError = true)
    {

        if (function_exists('isLoggedIn') && isLoggedIn()) {

            if ($bLogError) {
                $sPage = ArrayHelper::getFromArray('REQUEST_URI', $_SERVER);
                log_message('error', '401 Unauthorised --> ' . $sPage);
            }

            $sMessage = 'The page you are trying to view is restricted. Sadly you do not have enough ';
            $sMessage .= 'permissions to see its content.';

            if (function_exists('wasAdmin') && wasAdmin()) {

                $oUserModel = Factory::model('User', 'nails/module-auth');
                $oRecovery  = $oUserModel->getAdminRecoveryData();

                $sMessage .= '<br /><br />';
                $sMessage .= '<small>';
                $sMessage .= 'However, it looks like you are logged in as someone else.';
                $sMessage .= '<br />' . anchor($oRecovery->loginUrl, 'Log back in as ' . $oRecovery->name);
                $sMessage .= ' and try again.';
                $sMessage .= '</small>';
            }

            set_status_header(401);
            $this->renderErrorView(
                '401',
                [
                    'sSubject' => '401 Unauthorized',
                    'sMessage' => $sMessage,
                ]
            );
            exit(401);

        } else {

            $oSession = Factory::service('Session', 'nails/module-auth');
            $oInput   = Factory::service('Input');
            $sMessage = 'Sorry, you need to be logged in to see that page.';

            $oSession->setFlashData('message', $sMessage);

            if ($oInput->server('REQUEST_URI')) {
                $sReturn = $oInput->server('REQUEST_URI');
            } elseif (uri_string()) {
                $sReturn = uri_string();
            } else {
                $sReturn = '';
            }

            $sReturn = $sReturn ? '?return_to=' . urlencode($sReturn) : '';

            redirect('auth/login' . $sReturn);
        }
    }