PR #458 - code improvement required by @maxxer
This commit is contained in:
@ -53,6 +53,7 @@ class TwoFactorEmailCodeGeneratorService implements ServiceInterface
|
|||||||
// check the sending emailYii::t(
|
// check the sending emailYii::t(
|
||||||
if(!$mailService->run()){
|
if(!$mailService->run()){
|
||||||
Yii::$app->session->addFlash('error', Yii::t('usuario','The email sending failed, please check your configuration.'));
|
Yii::$app->session->addFlash('error', Yii::t('usuario','The email sending failed, please check your configuration.'));
|
||||||
|
return false;
|
||||||
}else{
|
}else{
|
||||||
// put key in session
|
// put key in session
|
||||||
Yii::$app->session->set("email_code_time", date('Y-m-d H:i:s'));
|
Yii::$app->session->set("email_code_time", date('Y-m-d H:i:s'));
|
||||||
|
|||||||
@ -65,7 +65,10 @@ class TwoFactorSmsCodeGeneratorService implements ServiceInterface
|
|||||||
$user = $this->user;
|
$user = $this->user;
|
||||||
$mobilePhone=$user->getAuthTfMobilePhone();
|
$mobilePhone=$user->getAuthTfMobilePhone();
|
||||||
|
|
||||||
if( !(null===$mobilePhone) && $mobilePhone!='' ){
|
if( null===$mobilePhone || $mobilePhone=='' ){
|
||||||
|
Yii::$app->session->addFlash('error', Yii::t('usuario','Mobile phone not found, please check your profile'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// send sms
|
// send sms
|
||||||
$success = $this->smsSender->send($mobilePhone, $code);
|
$success = $this->smsSender->send($mobilePhone, $code);
|
||||||
if($success){
|
if($success){
|
||||||
@ -76,10 +79,6 @@ class TwoFactorSmsCodeGeneratorService implements ServiceInterface
|
|||||||
Yii::$app->session->addFlash('error', Yii::t('usuario','The sms sending failed, please check your configuration.'));
|
Yii::$app->session->addFlash('error', Yii::t('usuario','The sms sending failed, please check your configuration.'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else{
|
|
||||||
Yii::$app->session->addFlash('error', Yii::t('usuario','Mobile phone not found, please check your profile'));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,8 +60,9 @@ class TwoFactorEmailValidator extends TwoFactorCodeValidator
|
|||||||
$validators = $module->twoFactorAuthenticationValidators;
|
$validators = $module->twoFactorAuthenticationValidators;
|
||||||
$codeDurationTime = ArrayHelper::getValue($validators,$this->type.'.codeDurationTime', 300);
|
$codeDurationTime = ArrayHelper::getValue($validators,$this->type.'.codeDurationTime', 300);
|
||||||
|
|
||||||
if($interval > $codeDurationTime )
|
if($interval > $codeDurationTime ){
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
$emailCode = Yii::$app->session->get("email_code");
|
$emailCode = Yii::$app->session->get("email_code");
|
||||||
return $this->code==$emailCode;
|
return $this->code==$emailCode;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -59,8 +59,9 @@ class TwoFactorTextMessageValidator extends TwoFactorCodeValidator
|
|||||||
$validators = $module->twoFactorAuthenticationValidators;
|
$validators = $module->twoFactorAuthenticationValidators;
|
||||||
$codeDurationTime = ArrayHelper::getValue($validators,$this->type.'.codeDurationTime', 300);
|
$codeDurationTime = ArrayHelper::getValue($validators,$this->type.'.codeDurationTime', 300);
|
||||||
|
|
||||||
if($interval > $codeDurationTime )
|
if($interval > $codeDurationTime ){
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
$smsCode = Yii::$app->session->get("sms_code");
|
$smsCode = Yii::$app->session->get("sms_code");
|
||||||
return $this->code==$smsCode;
|
return $this->code==$smsCode;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -126,6 +126,7 @@ return [
|
|||||||
'Insert' => 'Inserisci',
|
'Insert' => 'Inserisci',
|
||||||
'Insert the code you received by SMS.' => 'Inserisci il codice ricevuto tramite SMS.',
|
'Insert the code you received by SMS.' => 'Inserisci il codice ricevuto tramite SMS.',
|
||||||
'Insert the code you received by email.' => 'Inserisci il codice ricevuto tramite email.',
|
'Insert the code you received by email.' => 'Inserisci il codice ricevuto tramite email.',
|
||||||
|
'Insert the mobile phone number where you want to receive text message in international format' => 'Inserisci il numero di telefono sul quale ricevere il messaggio di testo nel formato internazionale',
|
||||||
'Invalid login or password' => 'Utente o password non validi',
|
'Invalid login or password' => 'Utente o password non validi',
|
||||||
'Invalid or expired link' => 'Collegamento non valido o scaduto',
|
'Invalid or expired link' => 'Collegamento non valido o scaduto',
|
||||||
'Invalid password' => 'Password non valida',
|
'Invalid password' => 'Password non valida',
|
||||||
@ -141,6 +142,7 @@ return [
|
|||||||
'Login' => 'Accedi',
|
'Login' => 'Accedi',
|
||||||
'Logout' => 'Esci',
|
'Logout' => 'Esci',
|
||||||
'Manage users' => 'Gestisci gli utenti',
|
'Manage users' => 'Gestisci gli utenti',
|
||||||
|
'Mobile phone not found, please check your profile' => 'Il numero di telefono non è stato trovato. Verifica il tuo profilo',
|
||||||
'Mobile phone number' => 'Numero di cellulare',
|
'Mobile phone number' => 'Numero di cellulare',
|
||||||
'Mobile phone number successfully enabled.' => 'Il numero di cellulare è stato abilitato',
|
'Mobile phone number successfully enabled.' => 'Il numero di cellulare è stato abilitato',
|
||||||
'Name' => 'Nome',
|
'Name' => 'Nome',
|
||||||
@ -295,13 +297,7 @@ return [
|
|||||||
'{0, date, MMM dd, YYYY HH:mm}' => '{0, date, MMM dd, YYYY HH:mm}',
|
'{0, date, MMM dd, YYYY HH:mm}' => '{0, date, MMM dd, YYYY HH:mm}',
|
||||||
'{0, date, MMMM dd, YYYY HH:mm}' => '{0, date, dd MMMM YYYY HH:mm}',
|
'{0, date, MMMM dd, YYYY HH:mm}' => '{0, date, dd MMMM YYYY HH:mm}',
|
||||||
'{0} cannot be blank.' => '{0} non può essere vuoto.',
|
'{0} cannot be blank.' => '{0} non può essere vuoto.',
|
||||||
'Insert the mobile phone number where you want to receive text message in international format' => '',
|
|
||||||
'Mobile phone not found, please check your profile' => '',
|
|
||||||
'This is the code to insert to enable two factor authentication' => '',
|
'This is the code to insert to enable two factor authentication' => '',
|
||||||
'An email has been sent with instructions for resetting your password' => '@@È stata inviata un\'email con le istruzioni per azzerare la tua password@@',
|
'An email has been sent with instructions for resetting your password' => '@@È stata inviata un\'email con le istruzioni per azzerare la tua password@@',
|
||||||
'Insert the mobile phone number where you want to receive text message in international format.' => '@@Inserisci il numero di telefono sul quale ricevere il messaggio di testo nel formato internazionale@@',
|
|
||||||
'Insert the mobile phone number where you want to receive the SMS.' => '@@Inserisci il numero del cellulare sul quale ricevere l\'SMS.@@',
|
|
||||||
'Mobile phone number not registered.' => '@@L\'attivazione del numero di cellulare non è riuscita@@',
|
|
||||||
'Now you can resume the login process' => '@@Ora puoi riprendere il processo di autenticazione@@',
|
'Now you can resume the login process' => '@@Ora puoi riprendere il processo di autenticazione@@',
|
||||||
'Send new code' => '@@Invia un nuovo codice@@',
|
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user