/**
  * Finds user by either username or email
  *
  * @param string $emailOrUsername
  *
  * @return \abhimanyu\user\models\UserIdentity|null
  */
 public static function findByUsernameOrEmail($emailOrUsername)
 {
     if (filter_var($emailOrUsername, FILTER_VALIDATE_EMAIL)) {
         return UserIdentity::findByEmail($emailOrUsername);
     }
     return UserIdentity::findByUsername($emailOrUsername);
 }
 /**
  * Finds user by [[username]]
  *
  * @return User|null
  */
 public function getUser()
 {
     if ($this->_user === FALSE) {
         if (UserModule::$loginType == User::LOGIN_TYPE_EMAIL) {
             $this->_user = UserIdentity::findByEmail($this->username);
         } elseif (UserModule::$loginType == User::LOGIN_TYPE_USERNAME) {
             $this->_user = UserIdentity::findByUsername($this->username);
         } elseif (UserModule::$loginType == User::LOGIN_TYPE_BOTH) {
             $this->_user = UserIdentity::findByUsernameOrEmail($this->username);
         }
     }
     return $this->_user;
 }