mirror of
https://github.com/elyby/accounts.git
synced 2025-05-31 14:11:46 +05:30
Добавил генерацию jwt токена для формы подтверждения регистрации
This commit is contained in:
@@ -52,20 +52,16 @@ class SignupController extends Controller {
|
||||
public function actionConfirm() {
|
||||
$model = new ConfirmEmailForm();
|
||||
$model->load(Yii::$app->request->post());
|
||||
if (!$model->confirm()) {
|
||||
if (!($jwt = $model->confirm())) {
|
||||
return [
|
||||
'success' => false,
|
||||
'errors' => $this->normalizeModelErrors($model->getErrors()),
|
||||
];
|
||||
}
|
||||
|
||||
// TODO: не уверен, что логин должен быть здесь + нужно разобраться с параметрами установки куки авторизации и сессии
|
||||
$activationCode = $model->getActivationCodeModel();
|
||||
$account = $activationCode->account;
|
||||
Yii::$app->user->login($account);
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'jwt' => $jwt,
|
||||
];
|
||||
}
|
||||
|
||||
|
@@ -35,10 +35,14 @@ class ConfirmEmailForm extends BaseKeyConfirmationForm {
|
||||
$transaction->commit();
|
||||
} catch (ErrorException $e) {
|
||||
$transaction->rollBack();
|
||||
throw $e;
|
||||
if (YII_DEBUG) {
|
||||
throw $e;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return $account->getJWT();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user