mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-16 23:00:51 +03:00
add captcha into sing in (Вход на сайт с использованием captcha)
This commit is contained in:
parent
7f2f1248ae
commit
01873c0402
|
@ -69,30 +69,51 @@ class ActionLogin extends Action {
|
|||
* Проверяем есть ли такой юзер по логину
|
||||
*/
|
||||
if ((func_check(getRequest('login'),'mail') and $oUser=$this->User_GetUserByMail(getRequest('login'))) or $oUser=$this->User_GetUserByLogin(getRequest('login'))) {
|
||||
/**
|
||||
* Сверяем хеши паролей и проверяем активен ли юзер
|
||||
*/
|
||||
/**
|
||||
* Выбираем сценарий валидации
|
||||
*/
|
||||
$oUser->_setValidateScenario('signIn');
|
||||
/**
|
||||
* Заполняем поля (данные)
|
||||
*/
|
||||
$oUser->setCaptcha(getRequestStr('captcha'));
|
||||
/**
|
||||
* Запускаем валидацию
|
||||
*/
|
||||
if ($oUser->_Validate()) {
|
||||
/**
|
||||
* Сверяем хеши паролей и проверяем активен ли юзер
|
||||
*/
|
||||
|
||||
if ($oUser->getPassword()==func_encrypt(getRequest('password'))) {
|
||||
if (!$oUser->getActivate()) {
|
||||
$this->Message_AddErrorSingle($this->Lang_Get('user_not_activated', array('reactivation_path' => Router::GetPath('login') . 'reactivation')));
|
||||
return;
|
||||
}
|
||||
$bRemember=getRequest('remember',false) ? true : false;
|
||||
/**
|
||||
* Авторизуем
|
||||
*/
|
||||
$this->User_Authorization($oUser,$bRemember);
|
||||
/**
|
||||
* Определяем редирект
|
||||
*/
|
||||
$sUrl=Config::Get('module.user.redirect_after_login');
|
||||
if (getRequestStr('return-path')) {
|
||||
$sUrl=getRequestStr('return-path');
|
||||
}
|
||||
$this->Viewer_AssignAjax('sUrlRedirect',$sUrl ? $sUrl : Config::Get('path.root.web'));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* Получаем ошибки
|
||||
*/
|
||||
$this->Viewer_AssignAjax('aErrors',$oUser->_getValidateErrors());
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($oUser->getPassword()==func_encrypt(getRequest('password'))) {
|
||||
if (!$oUser->getActivate()) {
|
||||
$this->Message_AddErrorSingle($this->Lang_Get('user_not_activated', array('reactivation_path' => Router::GetPath('login') . 'reactivation')));
|
||||
return;
|
||||
}
|
||||
$bRemember=getRequest('remember',false) ? true : false;
|
||||
/**
|
||||
* Авторизуем
|
||||
*/
|
||||
$this->User_Authorization($oUser,$bRemember);
|
||||
/**
|
||||
* Определяем редирект
|
||||
*/
|
||||
$sUrl=Config::Get('module.user.redirect_after_login');
|
||||
if (getRequestStr('return-path')) {
|
||||
$sUrl=getRequestStr('return-path');
|
||||
}
|
||||
$this->Viewer_AssignAjax('sUrlRedirect',$sUrl ? $sUrl : Config::Get('path.root.web'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
$this->Message_AddErrorSingle($this->Lang_Get('user_login_bad'));
|
||||
}
|
||||
|
|
|
@ -32,6 +32,10 @@ class ModuleUser_EntityUser extends Entity {
|
|||
$this->aValidateRules[] = array('captcha', 'captcha', 'on' => array('registration'));
|
||||
}
|
||||
|
||||
if (Config::Get('general.sign.in.captcha')){
|
||||
$this->aValidateRules[] = array('captcha', 'captcha', 'on' => array('signIn'));
|
||||
}
|
||||
|
||||
parent::__construct($aParam);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,12 @@
|
|||
sFieldType = 'password'
|
||||
sFieldRules = 'required="true" rangelength="[2,20]"'
|
||||
sFieldLabel = $aLang.user_password}
|
||||
|
||||
{* Каптча *}
|
||||
{if {cfg name='general.reg.sign.in.captcha'}}
|
||||
{include file='forms/form.field.captcha.tpl'
|
||||
sFieldName = 'captcha'
|
||||
sFieldLabel = $aLang.registration_captcha}
|
||||
{/if}
|
||||
{* Запомнить *}
|
||||
{include file='forms/form.field.checkbox.tpl'
|
||||
sFieldName='remember'
|
||||
|
|
|
@ -17,6 +17,20 @@
|
|||
|
||||
<small class="validate-error-hide validate-error-login"></small>
|
||||
|
||||
{*
|
||||
* Каптча
|
||||
*
|
||||
* @scripts <framework>/js/livestreet/captcha.js
|
||||
*}
|
||||
|
||||
{if {cfg name='general.reg.sign.in.captcha'}}
|
||||
{hookb run="registration_captcha" isPopup=$isModal}
|
||||
<p class="form-login-field-captcha"><label for="js-form-login-captcha">{$aLang.registration_captcha}</label>
|
||||
<span {if ! $isModal}style="background-image: url({cfg name='path.framework.libs_vendor.web'}/kcaptcha/index.php?{$_sPhpSessionName}={$_sPhpSessionId});"{/if} class="form-auth-captcha js-form-auth-captcha"></span>
|
||||
<input type="text" name="captcha" value="" maxlength="3" id="js-form-login-captcha" class="width-100 js-ajax-validate js-form-login-captcha" />
|
||||
<small class="validate-error-hide validate-error-field-captcha"></small></p>
|
||||
{/hookb}
|
||||
{/if}
|
||||
{* Запомнить *}
|
||||
<p><label class="remember-label"><input type="checkbox" name="remember" checked> {$aLang.user_login_remember}</label></p>
|
||||
|
||||
|
|
Loading…
Reference in a new issue