title: Argument 1 passed to yii\web\User::login() must implement interface yii\web\IdentityInterfac, null given
body: <p>Im trying to create a login api and have followed the link <a href="https://github.com/yiisoft/yii2/blob/master/docs/guide/security-authentication.md">https://github.com/yiisoft/yii2/blob/master/docs/guide/security-authentication.md</a></p>
  
  <p>the above url says:</p>
  
  <blockquote>
    <p>To login a user, you may use the following code:</p>
  
  <pre><code>// find a user identity with the specified username.
  // note that you may want to check the password if needed
  $identity = User::findOne(['username' =&gt; $username]);
  
  // logs in the user 
  Yii::$app-&gt;user-&gt;login($identity);
  </code></pre>
    
    <p>where should be this line added in controller action or the class that implements IdentityInterface.    </p>
  </blockquote>
  
  <p>On adding the above line in controller action but i get error saying 
  <code>Argument 1 passed to yii\web\User::login() must implement interface yii\web\IdentityInterface, null given, called in C:\wamp\www\basic\controllers\MyController.php on line 202</code> and defined
  where as the class that i amy implementing Identity interface is actual a model called Myuser (app\models\myuser).</p>
  
  <p>Why does it say <code>yii\web\User::login()</code> must implement identity interface?</p>
  
  <p>And if it is to be added in Myuser class how are the posted parameters to be passed to the login function?</p>
  
  <p>Can anyone help me out in this?</p>