title: Cakephp 3 Error: Call to a member function identify() on a non-object
body: <p>I am new to cakephp and started learning cakephp3.2 directly
  I have created a function in my custom controller as follows.</p>
  
  <pre><code>public function login(){
      if($this-&gt;request-&gt;is('post')){
  
          $user = $this-&gt;auth-&gt;identify();
  
          if($user){
              $this-&gt;Auth-&gt;setUser($user);
              return $this-&gt;redirect($this-&gt;Auth-&gt;redirectUrl());
          }else{
              $this-&gt;Flash-&gt;error(__('Username or password is incorrect'), [
              'key' =&gt; 'auth'
          ]);
          }
  
      }
  }
  
  
  class AppController extends Controller
  {
  
  public function initialize()
  {
      parent::initialize();
      $this-&gt;loadComponent('RequestHandler');
      $this-&gt;loadComponent('Flash');
  
      $this-&gt;loadComponent('Auth',[
          'authenticate' =&gt; [
              'Form' =&gt; [
                  'fields' =&gt; [
                      'username' =&gt; 'email',
                      'password' =&gt; 'password'
                  ]
              ]
          ],
          'authError' =&gt; 'Did you really think you are allowed to see that?',
          'loginAction' =&gt; [
              'controller' =&gt; 'Users',
              'action' =&gt; 'login'
          ],
          'storage'=&gt;'Session'
      ]);
  
      $this-&gt;Auth-&gt;allow(['display']);
  }
  
  public function beforeRender(Event $event)
  {
      if (!array_key_exists('_serialize', $this-&gt;viewVars) &amp;&amp;
          in_array($this-&gt;response-&gt;type(), ['application/json', 'application/xml'])
      ) {
          $this-&gt;set('_serialize', true);
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I don't understand how to deal with it.Should I load any external component or helper ? </p>