Образован trait AccountFinder для поиска пользователя по его нику\мылу

Модель EmailActivation теперь умеет автоматически создавать своих правильных потомков по соответствующему типу
Добавлена форма восстановления пароля и её обработчик (без контроллера)
This commit is contained in:
ErickSkrauch
2016-05-10 22:40:06 +03:00
parent ce2e68faf6
commit a29cb76cbf
21 changed files with 664 additions and 62 deletions

View File

@@ -0,0 +1,27 @@
<?php
namespace api\traits;
use common\models\Account;
trait AccountFinder {
private $account;
public abstract function getLogin();
/**
* @return Account|null
*/
public function getAccount() {
if ($this->account === null) {
$this->account = Account::findOne([$this->getLoginAttribute() => $this->getLogin()]);
}
return $this->account;
}
public function getLoginAttribute() {
return strpos($this->getLogin(), '@') ? 'email' : 'username';
}
}