Exemplo n.º 1
0
    /**
     * Напоминание пароля
     */
    function remindAction()
    {
        #if (!$this->view->identity) {$this->_redirect('auth/login');}
        if (!$this->userRegistrationAllowed) {
            $this->_exit();
        }
        #http://ac.lh//auth/remind/hash/72c12639535879b758428c2b24b8cc6b
        //--< hash processing
        $hash = $this->_getParam('hash', '');
        if ($hash) {
            if ($this->view->identity) {
                $this->_redirect('auth/logout');
            }
            $row = $this->getRow('users', '"' . $hash . '"  = MD5(CONCAT(id, password2))');
            if ($row) {
                $row->password = $row->password2;
                $row->password2 = '';
                $res = $row->save();
                if ($res) {
                    $this->setN(FrontEnd::getMsg(array('auth', 'remindComplete')));
                }
            } else {
                $this->setN(FrontEnd::getMsg('dnf'), 'errors');
            }
            $this->_redirect('auth/login');
        }
        //-->
        $this->textRow('remind');
        $form = new Form_AuthRemind();
        if ($this->getRequest()->isPost()) {
            $rawData = $this->getRequest()->getPost();
            if ($form->isValid($rawData)) {
                $v = $form->getValues();
                $row = $this->getRow('users', 'username = "******" AND email = "' . $v['email'] . '"');
                if (!$row) {
                    $this->view->notifyerr[] = FrontEnd::getMsg(array('auth', 'userFailed'));
                } else {
                    $password2 = Aux::generatePassword();
                    $row->password2 = md5($password2);
                    $res = $row->save();
                    #d($res);
                    if ($res) {
                        $options = array('to' => $v['email'], 'subject' => 'данные доступа на сайт', 'body' => 'Это автоматический ответ на запрос напоминания пароля для логина ' . $v['username'] . '.
Так как все пароли хранятся на сайте в зашифрованном виде, у нас нет возможности напомнить Ваш пароль.
Для Вас сгенерирован новый пароль ' . $password2 . ', Вы можете установить его, перейдя по указанной ссылке: ' . $this->view->host . $this->view->urlt('remind') . 'hash/' . md5($row->id . $row->password2) . '
Если Вы не хотите менять текущий пароль на новый, ничего не делайте, просто удалите это письмо.
Спасибо.');
                        #d($options);
                        $res = FrontEnd::mail($options);
                        $this->view->notifymsg[] = FrontEnd::getMsg(array('auth', 'remindSuccess'));
                        $this->view->done = true;
                    }
                }
            } else {
                #$this->rsetN(FrontEnd::getMsg(array('form', 'errors')), 'errors');
                $this->view->notifyerr[] = FrontEnd::getMsg(array('form', 'errors'));
            }
            #$this->_redirect($this->view->requestUri);
        }
        $this->view->form = $form;
    }