mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-16 14:50:48 +03:00
Доработка авторизации
This commit is contained in:
parent
0c82944f86
commit
e329441a4f
|
@ -113,8 +113,7 @@ class ActionAuth extends Action
|
|||
/**
|
||||
* Сверяем хеши паролей и проверяем активен ли юзер
|
||||
*/
|
||||
|
||||
if ($oUser->getPassword() == func_encrypt(getRequest('password'))) {
|
||||
if ($this->User_VerifyAccessAuth($oUser) and $oUser->verifyPassword(getRequest('password'))) {
|
||||
if (!$oUser->getActivate()) {
|
||||
$this->Message_AddErrorSingle($this->Lang_Get('auth.login.notices.error_not_activated',
|
||||
array('reactivation_path' => Router::GetPath('auth/reactivation'))));
|
||||
|
@ -236,7 +235,7 @@ class ActionAuth extends Action
|
|||
if ($oReminder = $this->User_GetReminderByCode($this->GetParam(0))) {
|
||||
if (!$oReminder->getIsUsed() and strtotime($oReminder->getDateExpire()) > time() and $oUser = $this->User_GetUserById($oReminder->getUserId())) {
|
||||
$sNewPassword = func_generator(7);
|
||||
$oUser->setPassword(func_encrypt($sNewPassword));
|
||||
$oUser->setPassword($this->User_MakeHashPassword($sNewPassword));
|
||||
if ($this->User_Update($oUser)) {
|
||||
$oReminder->setDateUsed(date("Y-m-d H:i:s"));
|
||||
$oReminder->setIsUsed(1);
|
||||
|
@ -383,7 +382,7 @@ class ActionAuth extends Action
|
|||
*/
|
||||
if ($oUser->_Validate()) {
|
||||
$this->Hook_Run('registration_validate_after', array('oUser' => $oUser));
|
||||
$oUser->setPassword(func_encrypt($oUser->getPassword()));
|
||||
$oUser->setPassword($this->User_MakeHashPassword($oUser->getPassword()));
|
||||
if ($this->User_Add($oUser)) {
|
||||
$this->Hook_Run('registration_after', array('oUser' => $oUser));
|
||||
/**
|
||||
|
|
|
@ -459,8 +459,8 @@ class ActionSettings extends Action
|
|||
if (getRequestStr('password', '') != '') {
|
||||
if (func_check(getRequestStr('password'), 'password', 5)) {
|
||||
if (getRequestStr('password') == getRequestStr('password_confirm')) {
|
||||
if (func_encrypt(getRequestStr('password_now')) == $this->oUserCurrent->getPassword()) {
|
||||
$this->oUserCurrent->setPassword(func_encrypt(getRequestStr('password')));
|
||||
if ($this->oUserCurrent->verifyPassword(getRequestStr('password_now'))) {
|
||||
$this->oUserCurrent->setPassword($this->User_MakeHashPassword(getRequestStr('password')));
|
||||
} else {
|
||||
$bError = true;
|
||||
$this->Message_AddError($this->Lang_Get('user.settings.account.fields.password.notices.error'),
|
||||
|
|
|
@ -1951,4 +1951,38 @@ class ModuleUser extends Module
|
|||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Генерация хеша пароля
|
||||
*
|
||||
* @param $sPassword
|
||||
* @return string
|
||||
*/
|
||||
public function MakeHashPassword($sPassword)
|
||||
{
|
||||
return func_encrypt($sPassword);
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверка пароля
|
||||
*
|
||||
* @param $sPassword
|
||||
* @param $sHash
|
||||
* @return string
|
||||
*/
|
||||
public function VerifyPassword($sPassword, $sHash)
|
||||
{
|
||||
return $this->MakeHashPassword($sPassword) == $sHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверка доступа к авторизации
|
||||
*
|
||||
* @param $oUser
|
||||
* @return bool
|
||||
*/
|
||||
public function VerifyAccessAuth($oUser)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -646,6 +646,17 @@ class ModuleUser_EntityUser extends Entity
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверка пароля
|
||||
*
|
||||
* @param $sPassword
|
||||
* @return string
|
||||
*/
|
||||
public function verifyPassword($sPassword)
|
||||
{
|
||||
return $this->User_VerifyPassword($sPassword, $this->getPassword());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Устанавливает ID пользователя
|
||||
|
|
Loading…
Reference in a new issue