Добавлена передача email при входе в неактивированный аккаунт

This commit is contained in:
ErickSkrauch 2016-03-13 21:46:22 +03:00
parent 7b9119ef79
commit 6b04860f0e
3 changed files with 9 additions and 2 deletions

View File

@ -36,10 +36,16 @@ class AuthenticationController extends Controller {
$model = new LoginForm(); $model = new LoginForm();
$model->load(Yii::$app->request->post()); $model->load(Yii::$app->request->post());
if (($jwt = $model->login()) === false) { if (($jwt = $model->login()) === false) {
return [ $data = [
'success' => false, 'success' => false,
'errors' => $this->normalizeModelErrors($model->getErrors()), 'errors' => $this->normalizeModelErrors($model->getErrors()),
]; ];
if (ArrayHelper::getValue($data['errors'], 'login') === 'error.account_not_activated') {
$data['data']['email'] = $model->getAccount()->email;
}
return $data;
} }
return [ return [

View File

@ -68,7 +68,7 @@ class LoginForm extends BaseApiForm {
/** /**
* @return Account|null * @return Account|null
*/ */
protected function getAccount() { public function getAccount() {
if ($this->_account === NULL) { if ($this->_account === NULL) {
$attribute = strpos($this->login, '@') ? 'email' : 'username'; $attribute = strpos($this->login, '@') ? 'email' : 'username';
$this->_account = Account::findOne([$attribute => $this->login]); $this->_account = Account::findOne([$attribute => $this->login]);

View File

@ -43,6 +43,7 @@ class LoginCest {
'login' => 'error.account_not_activated', 'login' => 'error.account_not_activated',
], ],
]); ]);
$I->canSeeResponseJsonMatchesJsonPath('$.data.email');
$I->wantTo('don\'t see errors on login field if username is correct and exists in database'); $I->wantTo('don\'t see errors on login field if username is correct and exists in database');
$route->login('Admin'); $route->login('Admin');