Ejemplo n.º 1
0
 /**
  * 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);
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
Ejemplo n.º 3
0
 public function actionEmail()
 {
     $user = UserIdentity::findByUsername(Yii::$app->user->identity->username);
     return $this->render('email', ['user' => $user]);
 }