mirror of
https://github.com/elyby/accounts.git
synced 2024-12-27 07:30:18 +05:30
Добавлена передача email при входе в неактивированный аккаунт
This commit is contained in:
parent
7b9119ef79
commit
6b04860f0e
@ -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 [
|
||||||
|
@ -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]);
|
||||||
|
@ -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');
|
||||||
|
Loading…
Reference in New Issue
Block a user