mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Merge branch 'master' into profile
This commit is contained in:
@@ -36,10 +36,16 @@ class AuthenticationController extends Controller {
|
||||
$model = new LoginForm();
|
||||
$model->load(Yii::$app->request->post());
|
||||
if (($jwt = $model->login()) === false) {
|
||||
return [
|
||||
$data = [
|
||||
'success' => false,
|
||||
'errors' => $this->normalizeModelErrors($model->getErrors()),
|
||||
];
|
||||
|
||||
if (ArrayHelper::getValue($data['errors'], 'login') === 'error.account_not_activated') {
|
||||
$data['data']['email'] = $model->getAccount()->email;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
return [
|
||||
|
@@ -2,6 +2,7 @@
|
||||
namespace api\controllers;
|
||||
|
||||
use api\models\ConfirmEmailForm;
|
||||
use api\models\RepeatAccountActivationForm;
|
||||
use api\models\RegistrationForm;
|
||||
use Yii;
|
||||
use yii\filters\AccessControl;
|
||||
@@ -12,13 +13,13 @@ class SignupController extends Controller {
|
||||
public function behaviors() {
|
||||
return ArrayHelper::merge(parent::behaviors(), [
|
||||
'authenticator' => [
|
||||
'except' => ['index', 'confirm'],
|
||||
'except' => ['index', 'repeat-message', 'confirm'],
|
||||
],
|
||||
'access' => [
|
||||
'class' => AccessControl::class,
|
||||
'rules' => [
|
||||
[
|
||||
'actions' => ['index', 'confirm'],
|
||||
'actions' => ['index', 'repeat-message', 'confirm'],
|
||||
'allow' => true,
|
||||
'roles' => ['?'],
|
||||
],
|
||||
@@ -31,6 +32,7 @@ class SignupController extends Controller {
|
||||
return [
|
||||
'register' => ['POST'],
|
||||
'confirm' => ['POST'],
|
||||
'new-message' => ['POST'],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -49,6 +51,31 @@ class SignupController extends Controller {
|
||||
];
|
||||
}
|
||||
|
||||
public function actionRepeatMessage() {
|
||||
$model = new RepeatAccountActivationForm();
|
||||
$model->load(Yii::$app->request->post());
|
||||
if (!$model->sendRepeatMessage()) {
|
||||
$response = [
|
||||
'success' => false,
|
||||
'errors' => $this->normalizeModelErrors($model->getErrors()),
|
||||
];
|
||||
|
||||
if ($response['errors']['email'] === 'error.recently_sent_message') {
|
||||
$activeActivation = $model->getActiveActivation();
|
||||
$response['data'] = [
|
||||
'canRepeatIn' => $activeActivation->created_at - time() + RepeatAccountActivationForm::REPEAT_FREQUENCY,
|
||||
'repeatFrequency' => RepeatAccountActivationForm::REPEAT_FREQUENCY,
|
||||
];
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
];
|
||||
}
|
||||
|
||||
public function actionConfirm() {
|
||||
$model = new ConfirmEmailForm();
|
||||
$model->load(Yii::$app->request->post());
|
||||
|
Reference in New Issue
Block a user