Files left out of merge
This commit is contained in:
@ -397,7 +397,7 @@ class SettingsController extends Controller
|
|||||||
public function actionConfirm($id, $code)
|
public function actionConfirm($id, $code)
|
||||||
{
|
{
|
||||||
$user = $this->userQuery->whereId($id)->one();
|
$user = $this->userQuery->whereId($id)->one();
|
||||||
|
|
||||||
if ($user === null || MailChangeStrategyInterface::TYPE_INSECURE === $this->module->emailChangeStrategy) {
|
if ($user === null || MailChangeStrategyInterface::TYPE_INSECURE === $this->module->emailChangeStrategy) {
|
||||||
throw new NotFoundHttpException();
|
throw new NotFoundHttpException();
|
||||||
}
|
}
|
||||||
@ -454,15 +454,14 @@ class SettingsController extends Controller
|
|||||||
public function actionTwoFactor($id)
|
public function actionTwoFactor($id)
|
||||||
{
|
{
|
||||||
$choice=Yii::$app->request->post('choice');
|
$choice=Yii::$app->request->post('choice');
|
||||||
/** @var User $user */
|
/** @var User $user */
|
||||||
$user = $this->userQuery->whereId($id)->one();
|
$user = $this->userQuery->whereId($id)->one();
|
||||||
|
|
||||||
if (null === $user) {
|
if (null === $user) {
|
||||||
throw new NotFoundHttpException();
|
throw new NotFoundHttpException();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($choice)
|
switch ($choice) {
|
||||||
{
|
|
||||||
case 'google-authenticator':
|
case 'google-authenticator':
|
||||||
$uri = $this->make(TwoFactorQrCodeUriGeneratorService::class, [$user])->run();
|
$uri = $this->make(TwoFactorQrCodeUriGeneratorService::class, [$user])->run();
|
||||||
return $this->renderAjax('two-factor', ['id' => $id, 'uri' => $uri]);
|
return $this->renderAjax('two-factor', ['id' => $id, 'uri' => $uri]);
|
||||||
@ -473,9 +472,8 @@ class SettingsController extends Controller
|
|||||||
// get mobile phone, if exists
|
// get mobile phone, if exists
|
||||||
$mobilePhone=$user->getAuthTfMobilePhone();
|
$mobilePhone=$user->getAuthTfMobilePhone();
|
||||||
$smsCode = $this->make(TwoFactorSmsCodeGeneratorService::class, [$user])->run();
|
$smsCode = $this->make(TwoFactorSmsCodeGeneratorService::class, [$user])->run();
|
||||||
return $this->renderAjax('two-factor-sms', ['id' => $id, 'code' => $smsCode, 'mobilePhone' => $mobilePhone] );
|
return $this->renderAjax('two-factor-sms', ['id' => $id, 'code' => $smsCode, 'mobilePhone' => $mobilePhone]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function actionTwoFactorEnable($id)
|
public function actionTwoFactorEnable($id)
|
||||||
@ -497,17 +495,17 @@ class SettingsController extends Controller
|
|||||||
}
|
}
|
||||||
$code = Yii::$app->request->get('code');
|
$code = Yii::$app->request->get('code');
|
||||||
$module = Yii::$app->getModule('user');
|
$module = Yii::$app->getModule('user');
|
||||||
$validators = $module->twoFactorAuthenticationValidators;
|
$validators = $module->twoFactorAuthenticationValidators;
|
||||||
$choice = Yii::$app->request->get('choice');
|
$choice = Yii::$app->request->get('choice');
|
||||||
$codeDurationTime = ArrayHelper::getValue($validators,$choice.'.codeDurationTime', 300);
|
$codeDurationTime = ArrayHelper::getValue($validators, $choice.'.codeDurationTime', 300);
|
||||||
$class = ArrayHelper::getValue($validators,$choice.'.class');
|
$class = ArrayHelper::getValue($validators, $choice.'.class');
|
||||||
|
|
||||||
$object = $this
|
$object = $this
|
||||||
->make($class, [$user, $code, $this->module->twoFactorAuthenticationCycles]);
|
->make($class, [$user, $code, $this->module->twoFactorAuthenticationCycles]);
|
||||||
$success = $object->validate();
|
$success = $object->validate();
|
||||||
$success = $success && $user->updateAttributes(['auth_tf_enabled' => '1','auth_tf_type' => $choice]);
|
$success = $success && $user->updateAttributes(['auth_tf_enabled' => '1','auth_tf_type' => $choice]);
|
||||||
$message = $success? $object->getSuccessMessage():$object->getUnsuccessMessage($codeDurationTime);
|
$message = $success ? $object->getSuccessMessage() : $object->getUnsuccessMessage($codeDurationTime);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'success' => $success,
|
'success' => $success,
|
||||||
'message' => $message
|
'message' => $message
|
||||||
@ -601,9 +599,9 @@ class SettingsController extends Controller
|
|||||||
Yii::$app->response->format = Response::FORMAT_JSON;
|
Yii::$app->response->format = Response::FORMAT_JSON;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
*
|
*
|
||||||
* @var User $user
|
*
|
||||||
|
* @var User $user
|
||||||
*/
|
*/
|
||||||
$user = $this->userQuery->whereId($id)->one();
|
$user = $this->userQuery->whereId($id)->one();
|
||||||
|
|
||||||
@ -616,13 +614,13 @@ class SettingsController extends Controller
|
|||||||
$mobilePhone = Yii::$app->request->get('mobilephone');
|
$mobilePhone = Yii::$app->request->get('mobilephone');
|
||||||
$currentMobilePhone = $user->getAuthTfMobilePhone();
|
$currentMobilePhone = $user->getAuthTfMobilePhone();
|
||||||
$success=false;
|
$success=false;
|
||||||
if($currentMobilePhone==$mobilePhone){
|
if ($currentMobilePhone==$mobilePhone) {
|
||||||
$success=true;
|
$success=true;
|
||||||
}else{
|
} else {
|
||||||
$success = $user->updateAttributes(['auth_tf_mobile_phone' => $mobilePhone]);
|
$success = $user->updateAttributes(['auth_tf_mobile_phone' => $mobilePhone]);
|
||||||
$success = $success && $this->make(TwoFactorSmsCodeGeneratorService::class, [$user])->run();
|
$success = $success && $this->make(TwoFactorSmsCodeGeneratorService::class, [$user])->run();
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'success' => $success,
|
'success' => $success,
|
||||||
'message' => $success
|
'message' => $success
|
||||||
|
|||||||
@ -67,8 +67,8 @@ class User extends ActiveRecord implements IdentityInterface
|
|||||||
use ContainerAwareTrait;
|
use ContainerAwareTrait;
|
||||||
|
|
||||||
// following constants are used on secured email changing process
|
// following constants are used on secured email changing process
|
||||||
const OLD_EMAIL_CONFIRMED = 0b01;
|
public const OLD_EMAIL_CONFIRMED = 0b01;
|
||||||
const NEW_EMAIL_CONFIRMED = 0b10;
|
public const NEW_EMAIL_CONFIRMED = 0b10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Plain password. Used for model validation
|
* @var string Plain password. Used for model validation
|
||||||
|
|||||||
Reference in New Issue
Block a user