/** * Delete session record(s) when delete user login * @param int $user_id */ public function deleteSession($user_id) { // get user login by user Id Zend_Loader::loadClass('Wbusers'); $users = new Wbusers(); $where = $users->getAdapter()->quoteInto('id = ?', $user_id); $row = $users->fetchRow($where); unset($where); if (isset($row->login)) { $where = $this->getAdapter()->quoteInto('login = ?', $row->login); $this->delete($where); } else { throw new Exception(__METHOD__ . ' : User login not found'); } }
public function userDeleteAction() { $user_id = $this->_request->getParam('user_id'); if (empty($user_id)) { throw new Exception(__METHOD__ . ' : Empty input parameters'); } // clear session data Zend_Loader::loadClass('Wbphpsession'); $table_session = new Wbphpsession(); $table_session->deleteSession($user_id); // delete user account $table = new Wbusers(); $where = $table->getAdapter()->quoteInto('id = ?', $user_id); try { $table->delete($where); } catch (Zend_Exception $e) { $this->view->exception = $this->view->translate->_('Exception') . ' : ' . $e->getMessage(); } // clear all cache $this->cache_helper->clearAllCache(); // render $this->_forward('user-index', 'admin'); // action, controller }
public function forgotPasswordAction() { Zend_Loader::loadClass('FormForgotPassword'); $form = new formForgotPassword(); if ($this->_request->isPost()) { /* Проверяем валидность данных формы */ if ($form->isValid($this->_getAllParams())) { $db = Zend_Registry::get('db_bacula'); Zend_Loader::loadClass('Wbusers'); $table = new Wbusers(); // ищем email $select = $table->select()->where('login = ?', $this->_getParam('login'))->where('email = ?', $this->_getParam('email')); $row = $table->fetchRow($select); /* login + email найдены ? */ if ($row) { // генерируем новый пароль $new_password = md5(uniqid(rand())); // высылаем пароль $res = $this->emailForgotPassword($row->email, $row->name, $new_password); if ($res) { // сохраняем пароль в БД if (Zend_Registry::get('DB_ADAPTER') != 'PDO_SQLITE') { // Sqlite do not have MD5 function $new_password = md5($new_password); } $data = array('pwd' => $new_password); $where = $table->getAdapter()->quoteInto('id = ?', $row->id); $table->update($data, $where); // goto home page $this->view->msg = $this->view->translate->_("New password set"); $this->_redirector->gotoSimple('login', 'auth', null, array('from_forgot' => 1)); // action, controller } else { $this->view->msg = $this->view->translate->_("Error while sending email. Email not send"); } } else { sleep(2); // TODO increase this value $this->view->msg = $this->view->translate->_("Username or email is incorrect"); } } } /* Если данные не передавались или неверный логин, то выводим форму для авторизации */ $this->view->title = $this->view->translate->_('Reset password'); $this->view->form = $form; }