title: OctoberCMS: How to check if user logged in for all pages
body: <p>I am using <a href="https://octobercms.com/plugin/rainlab-user" rel="nofollow noreferrer">the following code</a> (in the code section of a page) to redirect users to the login page if they are not logged in:</p>
  
  <pre><code>function onStart()
  {
      $user = $this-&gt;account-&gt;user();
      if(!$user)
      {
          return Redirect::to('/login');
      }
  }
  </code></pre>
  
  <p>How can I avoid doing this in every page and perform this checking in one place for all the pages that need authentication?</p>