ActionLogin

Package actions
Inheritance class ActionLogin » Action » LsObject
Since 1.0
Source Code /classes/actions/ActionLogin.class.php
Обрабатывые авторизацию

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
aParams array Список параметров из URL Action
aParamsEventMatch array Список совпадений по регулярному выражению для евента Action
aRegisterEvent array Список зарегистрированных евентов Action
oEngine Engine|null Объект ядра Action
sActionTemplate string|null Шаблон экшена Action
sCurrentAction null|string Текущий экшен Action
sCurrentEvent string|null Текущий евент Action
sCurrentEventName string|null Имя текущий евента Action
sDefaultEvent string|null Дефолтный евент Action

Public Methods

Hide inherited methods

MethodDescriptionDefined By
EventShutdown() Выполняется при завершение экшена, после вызова основного евента Action
ExecEvent() Запускает евент на выполнение Action
GetActionClass() Получить каталог с шаблонами экшена(совпадает с именем класса) Action
GetCurrentEventName() Возвращает имя евента Action
GetDefaultEvent() Получает евент по умолчанию Action
GetParam() Получает параметр из URL по его номеру, если его нет то null Action
GetParams() Получает список параметров из УРЛ Action
GetTemplate() Получить шаблон Action
Init() Инициализация ActionLogin
SetDefaultEvent() Устанавливает евент по умолчанию Action
SetParam() Установить значение параметра(эмуляция параметра в URL). Action
__call() Ставим хук на вызов неизвестного метода и считаем что хотели вызвать метод какого либо модуля Action
__construct() Конструктор Action

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
AddEvent() Добавляет евент в экшен Action
AddEventPreg() Добавляет евент в экшен, используя регулярное вырожение для евента и параметров Action
EventAjaxLogin() Ajax авторизация ActionLogin
EventAjaxReactivation() Ajax повторной активации ActionLogin
EventAjaxReminder() Ajax запрос на восстановление пароля ActionLogin
EventExit() Обрабатываем процесс разлогинивания ActionLogin
EventLogin() Обрабатываем процесс залогинивания ActionLogin
EventNotFound() Вызывается в том случаи если не найден евент который запросили через URL Action
EventReactivation() Повторный запрос активации ActionLogin
EventReminder() Обработка напоминания пароля, подтверждение смены пароля ActionLogin
GetEventMatch() Возвращает элементы совпадения по регулярному выражению для евента Action
GetParamEventMatch() Возвращает элементы совпадения по регулярному выражению для параметров евента Action
RegisterEvent() Регистрируем евенты ActionLogin
SetTemplate() Устанавливает какой шаблон выводить Action
SetTemplateAction() Устанавливает какой шаблон выводить Action

Method Details

EventAjaxLogin() method
protected void EventAjaxLogin()
Source Code: /classes/actions/ActionLogin.class.php#56 (show)
protected function EventAjaxLogin() {
    
/**
     * Устанвливаем формат Ajax ответа
     */
    
$this->Viewer_SetResponseAjax('json');
    
/**
     * Логин и пароль являются строками?
     */
    
if (!is_string(getRequest('login')) or !is_string(getRequest('password'))) {
        
$this->Message_AddErrorSingle($this->Lang_Get('system_error'));
        return;
    }
    
/**
     * Проверяем есть ли такой юзер по логину
     */
    
if ((func_check(getRequest('login'),'mail') and $oUser=$this->User_GetUserByMail(getRequest('login')))  or  $oUser=$this->User_GetUserByLogin(getRequest('login'))) {
        
/**
         * Сверяем хеши паролей и проверяем активен ли юзер
         */

        
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 (
getRequest('return-path')) {
                
$sUrl=getRequest('return-path');
            }
            
$this->Viewer_AssignAjax('sUrlRedirect',$sUrl $sUrl Config::Get('path.root.web'));
            return;
        }
    }
    
$this->Message_AddErrorSingle($this->Lang_Get('user_login_bad'));
}

Ajax авторизация

EventAjaxReactivation() method
protected void EventAjaxReactivation()
Source Code: /classes/actions/ActionLogin.class.php#112 (show)
protected function EventAjaxReactivation() {
    
$this->Viewer_SetResponseAjax('json');

    if ((
func_check(getRequest('mail'), 'mail') and $oUser $this->User_GetUserByMail(getRequest('mail')))) {
        if (
$oUser->getActivate()) {
            
$this->Message_AddErrorSingle($this->Lang_Get('registration_activate_error_reactivate'));
            return;
        } else {
            
$oUser->setActivateKey(md5(func_generator() . time()));
            if (
$this->User_Update($oUser)) {
                
$this->Message_AddNotice($this->Lang_Get('reactivation_send_link'));
                
$this->Notify_SendReactivationCode($oUser);
                return;
            }
        }
    }

    
$this->Message_AddErrorSingle($this->Lang_Get('password_reminder_bad_email'));
}

Ajax повторной активации

EventAjaxReminder() method
protected void EventAjaxReminder()
Source Code: /classes/actions/ActionLogin.class.php#157 (show)
protected function EventAjaxReminder() {
    
/**
     * Устанвливаем формат Ajax ответа
     */
    
$this->Viewer_SetResponseAjax('json');
    
/**
     * Пользователь с таким емайлом существует?
     */
    
if ((func_check(getRequest('mail'),'mail') and $oUser=$this->User_GetUserByMail(getRequest('mail')))) {
        
/**
         * Формируем и отправляем ссылку на смену пароля
         */
        
$oReminder=Engine::GetEntity('User_Reminder');
        
$oReminder->setCode(func_generator(32));
        
$oReminder->setDateAdd(date("Y-m-d H:i:s"));
        
$oReminder->setDateExpire(date("Y-m-d H:i:s",time()+60*60*24*7));
        
$oReminder->setDateUsed(null);
        
$oReminder->setIsUsed(0);
        
$oReminder->setUserId($oUser->getId());
        if (
$this->User_AddReminder($oReminder)) {
            
$this->Message_AddNotice($this->Lang_Get('password_reminder_send_link'));
            
$this->Notify_SendReminderCode($oUser,$oReminder);
            return;
        }
    }
    
$this->Message_AddError($this->Lang_Get('password_reminder_bad_email'),$this->Lang_Get('error'));
}

Ajax запрос на восстановление пароля

EventExit() method
protected void EventExit()
Source Code: /classes/actions/ActionLogin.class.php#149 (show)
protected function EventExit() {
    
$this->Security_ValidateSendForm();
    
$this->User_Logout();
    
$this->Viewer_Assign('bRefreshToHome',true);
}

Обрабатываем процесс разлогинивания

EventLogin() method
protected void EventLogin()
Source Code: /classes/actions/ActionLogin.class.php#136 (show)
protected function EventLogin() {
    
/**
     * Если уже авторизирован
     */
    
if($this->User_GetUserCurrent()) {
        
Router::Location(Config::Get('path.root.web').'/');
    }
    
$this->Viewer_AddHtmlTitle($this->Lang_Get('login'));
}

Обрабатываем процесс залогинивания По факту только отображение шаблона, дальше вступает в дело Ajax

EventReactivation() method
protected void EventReactivation()
Source Code: /classes/actions/ActionLogin.class.php#102 (show)
protected function EventReactivation() {
    if(
$this->User_GetUserCurrent()) {
        
Router::Location(Config::Get('path.root.web').'/');
    }

    
$this->Viewer_AddHtmlTitle($this->Lang_Get('reactivation'));
}

Повторный запрос активации

EventReminder() method
protected void EventReminder()
Source Code: /classes/actions/ActionLogin.class.php#188 (show)
protected function EventReminder() {
    
/**
     * Устанавливаем title страницы
     */
    
$this->Viewer_AddHtmlTitle($this->Lang_Get('password_reminder'));
    
/**
     * Проверка кода на восстановление пароля и генерация нового пароля
     */
    
if (func_check($this->GetParam(0),'md5')) {
        
/**
         * Проверка кода подтверждения
         */
        
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));
                if (
$this->User_Update($oUser)) {
                    
$oReminder->setDateUsed(date("Y-m-d H:i:s"));
                    
$oReminder->setIsUsed(1);
                    
$this->User_UpdateReminder($oReminder);
                    
$this->Notify_SendReminderPassword($oUser,$sNewPassword);
                    
$this->SetTemplateAction('reminder_confirm');
                    return ;
                }
            }
        }
        
$this->Message_AddErrorSingle($this->Lang_Get('password_reminder_bad_code'),$this->Lang_Get('error'));
        return 
Router::Action('error');
    }
}

Обработка напоминания пароля, подтверждение смены пароля

Init() method
public void Init()
Source Code: /classes/actions/ActionLogin.class.php#29 (show)
public function Init() {
    
/**
     * Устанавливаем дефолтный евент
     */
    
$this->SetDefaultEvent('index');
    
/**
     * Отключаем отображение статистики выполнения
     */
    
Router::SetIsShowStats(false);
}

Инициализация

RegisterEvent() method
protected void RegisterEvent()
Source Code: /classes/actions/ActionLogin.class.php#43 (show)
protected function RegisterEvent() {
    
$this->AddEvent('index','EventLogin');
    
$this->AddEvent('exit','EventExit');
    
$this->AddEvent('reminder','EventReminder');
    
$this->AddEvent('reactivation','EventReactivation');

    
$this->AddEvent('ajax-login','EventAjaxLogin');
    
$this->AddEvent('ajax-reminder','EventAjaxReminder');
    
$this->AddEvent('ajax-reactivation','EventAjaxReactivation');
}

Регистрируем евенты