Exemplo n.º 1
0
 /**
  * Resets user's password and send it to email
  * @param UserAccount $user
  */
 public function resetPassword(UserAccount $user)
 {
     if ($user->status != UserAccount::STATUS_ACTIVE) {
         if (!$this->allowActivationOnPasswordReset) {
             throw new CException('Can\'t reset password for inactive users.');
         } else {
             $identity = Identity::model()->findByAttributes(array('user_id' => $user->id, 'type' => Identity::TYPE_EMAIL, 'status' => Identity::STATUS_NEED_CONFIRMATION));
             $identity->userIdentityConfirmation->confirm();
         }
     }
     $emailAddr = $user->getActiveEmail();
     $newPassword = $this->randomPassword();
     $user->setPassword($newPassword);
     $user->save(false, array('password'));
     $email = new YiiMailer('resetPassword', $data = array('newPassword' => $newPassword, 'description' => $description = 'Password reset'));
     $email->setSubject($description);
     $email->setTo($emailAddr);
     $email->setFrom(Yii::app()->params['noreplyAddress'], Yii::app()->name, FALSE);
     Yii::log('Sendign reset password mail to ' . $emailAddr);
     if ($email->send()) {
         Yii::log('Ok');
     } else {
         Yii::log('Failed');
         throw new CException('Failed to send the email');
     }
 }
Exemplo n.º 2
0
 public function delete($aId)
 {
     foreach ($aId as $row) {
         try {
             $oAccount = new UserAccount($row);
             $oAccount->delete();
         } catch (Exception $e) {
             $this->addError($e->getMessage());
         }
     }
     $this->jumpBack();
 }
Exemplo n.º 3
0
 public function generate()
 {
     $parseData = array('name' => $this->szName);
     if (!empty($this->currentUserId)) {
         try {
             $user = new UserAccount($this->currentUserId);
             $parseData['currentUser'] = $user->getParseData();
         } catch (Exception $e) {
         }
     }
     return UParser::parsePHPFile(__DIR__ . DIRECTORY_SEPARATOR . 'tpl/userselect.tpl', $parseData);
 }
Exemplo n.º 4
0
 public function veriflyAction()
 {
     switch ($this->request->getPost('type')) {
         case "login":
             break;
         case "register":
             $this->tag->setTitle('注册中。。。');
             $username = $this->request->getPost('username');
             $email = $this->request->getPost("email");
             if (CheckController::usernameCheck($username)) {
                 $errmsg .= "用户名已存在辣~";
             }
             if (CheckController::emailCheck($email)) {
                 $errmsg .= "邮箱已经被使用辣~";
             }
             if (!$errmsg) {
                 $token = md5($username . $username . $regtime);
                 //创建用于激活识别码
                 $token_exptime = time() + 60 * 60 * 24;
                 //过期时间为24小时后
                 $user = new UserAccount();
                 $user->username = $username;
                 //用户名
                 $user->email = $email;
                 //邮箱
                 $user->regtime = time();
                 //注册时间
                 $user->salt = rand(100000, 999999);
                 //随机生成salt值
                 $user->password = md5(md5('12345678') . $user->salt);
                 //默认密码12346
                 $user->token = $token;
                 //激活识别码
                 $user->token_exptime = $token_exptime;
                 //验证超时时间
                 if ($user->save() == true) {
                     $this->tag->setTitle('注册成功 | FiSkinAlcon');
                     $this->flash->success("注册成功!一封激活邮件已发往您的邮箱,请及时登录查看喵~");
                 } else {
                     $this->tag->setTitle('新用户注册 | FiSkinAlcon');
                     foreach ($user->getMessages() as $message) {
                         $errmsg .= getMessage() . "<br/>";
                     }
                     $this->flash->error($errmsg);
                 }
             }
             break;
     }
 }
Exemplo n.º 5
0
 public function saveUser($sender, $params)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($params->CallbackParameter->firstName) || ($firstName = trim($params->CallbackParameter->firstName)) === '') {
             throw new Exception('System Error: firstName is mandatory!');
         }
         if (!isset($params->CallbackParameter->lastName) || ($lastName = trim($params->CallbackParameter->lastName)) === '') {
             throw new Exception('System Error: lastName is mandatory!');
         }
         if (!isset($params->CallbackParameter->userName) || ($userName = trim($params->CallbackParameter->userName)) === '') {
             throw new Exception('System Error: userName is mandatory!');
         }
         if (!isset($params->CallbackParameter->roleid) || !($role = Role::get($params->CallbackParameter->roleid)) instanceof Role) {
             throw new Exception('System Error: role is mandatory!');
         }
         $newpassword = trim($params->CallbackParameter->newpassword);
         if (!isset($params->CallbackParameter->userid) || !($userAccount = UserAccount::get($params->CallbackParameter->userid)) instanceof UserAccount) {
             $userAccount = new UserAccount();
             $person = new Person();
             if ($newpassword === '') {
                 throw new Exception('System Error: new password is mandatory!');
             }
             $newpassword = sha1($newpassword);
         } else {
             $person = $userAccount->getPerson();
             if ($newpassword === '') {
                 $newpassword = $userAccount->getPassword();
             } else {
                 $newpassword = sha1($newpassword);
             }
         }
         //double check whether the username has been used
         $users = UserAccount::getAllByCriteria('username=? and id!=?', array($userName, $userAccount->getId()), false, 1, 1);
         if (count($users) > 0) {
             throw new Exception('Username(=' . $userName . ') has been used by another user, please choose another one!');
         }
         $person->setFirstName($firstName)->setLastName($lastName)->save();
         $userAccount->setUserName($userName)->setPassword($newpassword)->setPerson($person)->save();
         $results = $userAccount->clearRoles()->addRole($role)->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $params->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
Exemplo n.º 6
0
 /**
  * Get data and output in JSON
  *
  * @return void
  * @access public
  */
 public function getSearchLinkStatuses()
 {
     $metalib = new MetaLib();
     if (!$metalib->available()) {
         // MetaLib not enabled
         return $this->output(array(), JSON::STATUS_OK);
     }
     // Cache values and status in an array
     $results = array();
     $authorized = UserAccount::isAuthorized();
     foreach ($_REQUEST['id'] as $id) {
         $ird = explode('.', $id, 2);
         if (!isset($ird[1])) {
             continue;
         }
         $ird = $ird[1];
         $irdInfo = $metalib->getIRDInfo($ird);
         if ($irdInfo && ($authorized || strcasecmp($irdInfo['access'], 'guest') == 0)) {
             $results[] = array('id' => $id, 'status' => $irdInfo['searchable'] ? 'allowed' : 'nonsearchable');
         } else {
             $results[] = array('id' => $id, 'status' => 'denied');
         }
     }
     return $this->output($results, JSON::STATUS_OK);
 }
Exemplo n.º 7
0
 function launch($msg = null)
 {
     global $interface;
     global $configArray;
     global $user;
     if (!($user = UserAccount::isLoggedIn())) {
         require_once 'Login.php';
         Login::launch();
         exit;
     }
     // Save Data
     if (isset($_REQUEST['tagId'])) {
         //Remove the tag for the user.
         $resource = new Resource();
         if (isset($_REQUEST['resourceId'])) {
             $resource = $resource->staticGet('record_id', $_REQUEST['resourceId']);
             $resource->removeTag($_REQUEST['tagId'], $user, false);
             header('Location: ' . $configArray['Site']['path'] . '/Record/' . $_REQUEST['resourceId']);
             exit;
         } else {
             $resource->removeTag($_REQUEST['tagId'], $user, true);
             header('Location: ' . $configArray['Site']['path'] . '/MyResearch/Favorites');
             exit;
         }
     } else {
         //No id provided to delete raise an error?
         PEAR_Singleton::raiseError(new PEAR_Error('Tag Id Missing'));
     }
 }
Exemplo n.º 8
0
 protected function factoryColumn($userLogin)
 {
     $user = \UserAccount::getByLogin($userLogin);
     $this->column = new SocialNetworks('testName', [], null);
     $this->column->setDocument($user);
     return $this->column;
 }
Exemplo n.º 9
0
 /**
  * Constructor
  *
  * @access public
  */
 public function __construct()
 {
     global $configArray;
     global $user;
     global $interface;
     //$interface->caching = 1;
     // Setup Search Engine Connection
     $this->db = ConnectionManager::connectToIndex();
     // Connect to Database
     $this->catalog = ConnectionManager::connectToCatalog();
     // Set up object for formatting dates and times:
     $this->dateFormat = new VuFindDate();
     // Register Library Catalog Account
     if (isset($_POST['submit']) && !empty($_POST['submit'])) {
         if (isset($_POST['cat_username']) && isset($_POST['cat_password'])) {
             $username = $_POST['cat_username'];
             if (isset($_POST['login_target'])) {
                 $username = $_POST['login_target'] . '.' . $username;
             }
             $result = UserAccount::processCatalogLogin($username, $_POST['cat_password']);
             if ($result) {
                 $interface->assign('user', $user);
             } else {
                 $interface->assign('loginError', 'Invalid Patron Login');
             }
         }
     }
     // Retrieve the record from the index
     if (!($record = $this->db->getRecord($_REQUEST['id']))) {
         PEAR::raiseError(new PEAR_Error('Record Does Not Exist'));
     }
     $this->setRecord($_REQUEST['id'], $record);
 }
Exemplo n.º 10
0
 /**
  * (non-PHPdoc)
  * @see DetailsPageAbstract::saveItem()
  */
 public function saveItem($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         $task = null;
         if (isset($param->CallbackParameter->id) && !($task = Task::get(trim($param->CallbackParameter->id))) instanceof Task) {
             throw new Exception('Invalid Task passed in!');
         }
         if (!isset($param->CallbackParameter->instructions) || ($instructions = trim($param->CallbackParameter->instructions)) === '') {
             throw new Exception('Instructions are required!');
         }
         if (!isset($param->CallbackParameter->customerId) || !($customer = Customer::get(trim($param->CallbackParameter->customerId))) instanceof Customer) {
             throw new Exception('Invalid Customer Passed in!');
         }
         $tech = isset($param->CallbackParameter->techId) ? UserAccount::get(trim($param->CallbackParameter->techId)) : null;
         $order = isset($param->CallbackParameter->orderId) ? Order::get(trim($param->CallbackParameter->orderId)) : null;
         $dueDate = new UDate(trim($param->CallbackParameter->dueDate));
         $status = isset($param->CallbackParameter->statusId) ? TaskStatus::get(trim($param->CallbackParameter->statusId)) : null;
         if (!$task instanceof Task) {
             $task = Task::create($customer, $dueDate, $instructions, $tech, $order);
         } else {
             $task->setCustomer($customer)->setDueDate($dueDate)->setInstructions($instructions)->setTechnician($tech)->setFromEntityId($order instanceof Order ? $order->getId() : '')->setFromEntityName($order instanceof Order ? get_class($order) : '')->setStatus($status)->save();
         }
         // 			$results['url'] = '/task/' . $task->getId() . '.html?' . $_SERVER['QUERY_STRING'];
         $results['item'] = $task->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
Exemplo n.º 11
0
 function launch($msg = null)
 {
     global $interface;
     global $configArray;
     if (!($user = UserAccount::isLoggedIn())) {
         require_once 'Login.php';
         Login::launch();
         exit;
     }
     // Save Data
     if (isset($_POST['submit'])) {
         $this->saveChanges($user);
         // After changes are saved, send the user back to an appropriate page;
         // either the list they were viewing when they started editing, or the
         // overall favorites list.
         if (isset($_REQUEST['list_id'])) {
             $nextAction = 'MyList/' . $_REQUEST['list_id'];
         } elseif (isset($_REQUEST['lists'])) {
             if (is_array($_REQUEST['lists'])) {
                 $nextAction = 'MyList/' . $_REQUEST['lists'][0];
             } else {
                 $nextAction = 'MyList/' . $_REQUEST['lists'];
             }
         } else {
             $nextAction = 'Home';
         }
         header('Location: ' . $configArray['Site']['path'] . '/MyResearch/' . $nextAction);
         exit;
     }
     // Setup Search Engine Connection
     $class = $configArray['Index']['engine'];
     $db = new $class($configArray['Index']['url']);
     if ($configArray['System']['debugSolr']) {
         $db->debug = true;
     }
     // Get Record Information
     $resource = new Resource();
     $resource->record_id = $_GET['id'];
     $resource->source = $_GET['source'];
     if ($resource->find(true)) {
         $interface->assign('resource', $resource);
     }
     // Record ID
     $interface->assign('recordId', $_GET['id']);
     // Retrieve saved information about record
     $saved = $user->getSavedData($_GET['id'], $_GET['source']);
     // Add tag information
     $savedData = array();
     foreach ($saved as $current) {
         // If we're filtering to a specific list, skip any other lists:
         if (isset($_GET['list_id']) && $current->list_id != $_GET['list_id']) {
             continue;
         }
         $savedData[] = array('listId' => $current->list_id, 'listTitle' => $current->list_title, 'notes' => $current->notes, 'tags' => $this->getTags($user, $current->list_id));
     }
     $interface->assign('savedData', $savedData);
     $interface->assign('listFilter', $_GET['list_id']);
     $interface->setTemplate('edit.tpl');
     $interface->display('layout.tpl');
 }
Exemplo n.º 12
0
 protected function Form_PreRender()
 {
     $objExpansionMap[UserAccount::ExpandCreatedByObject] = true;
     $objExpansionMap[UserAccount::ExpandRole] = true;
     // Get Total Count b/c of Pagination
     $this->dtgUserAccount->TotalItemCount = UserAccount::CountAll();
     if ($this->dtgUserAccount->TotalItemCount == 0) {
         $this->dtgUserAccount->ShowHeader = false;
     } else {
         $objClauses = array();
         if ($objClause = $this->dtgUserAccount->OrderByClause) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = $this->dtgUserAccount->LimitClause) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = QQ::Expand(QQN::UserAccount()->CreatedByObject)) {
             array_push($objClauses, $objClause);
         }
         if ($objClause = QQ::Expand(QQN::UserAccount()->Role)) {
             $this->dtgUserAccount->DataSource = UserAccount::LoadAll($objClauses);
         }
         $this->dtgUserAccount->ShowHeader = true;
     }
 }
Exemplo n.º 13
0
 /**
  * Process incoming parameters and display the page.
  *
  * @return void
  * @access public
  */
 public function launch()
 {
     global $interface;
     global $configArray;
     // Don't let bots crawl holdings
     $this->disallowBots();
     if (!$this->hasHoldings && !(isset($configArray['Site']['ajaxRecordTabs']) && $configArray['Site']['ajaxRecordTabs'])) {
         $url = $configArray['Site']['url'] . "/Record/" . $_REQUEST['id'] . "/Description";
         header('Location: ' . $url);
     }
     // Do not cache holdings page
     $interface->caching = 0;
     // See if patron is logged in to pass details onto get holdings for
     // holds / recalls
     $patron = UserAccount::isLoggedIn() ? UserAccount::catalogLogin() : false;
     if (PEAR::isError($patron)) {
         $patron = false;
     }
     $interface->setPageTitle($this->recordDriver->getBreadcrumb());
     // Only fetch holdings if we actually need them (not needed for the basic page part of holdings when using ajax record tabs)
     if (!isset($configArray['Site']['ajaxRecordTabs']) || !$configArray['Site']['ajaxRecordTabs'] || isset($_REQUEST['subPage'])) {
         $interface->assign('holdingsMetadata', $this->recordDriver->getHoldings($patron));
     }
     $interface->assign('subTemplate', 'view-holdings.tpl');
     $interface->setTemplate('view.tpl');
     // Set Messages
     $interface->assign('infoMsg', $this->infoMsg);
     $interface->assign('errorMsg', $this->errorMsg);
     // Display Page
     $interface->display('layout.tpl');
 }
Exemplo n.º 14
0
 function Login()
 {
     global $configArray;
     // Fetch Salt
     $salt = $this->generateSalt();
     // HexDecode Password
     $password = pack('H*', $_GET['password']);
     // Decrypt Password
     /*
     require_once 'Crypt/Blowfish.php';
     $cipher = new Crypt_Blowfish($salt);
     $password = $cipher->decrypt($_GET['password']);
     */
     /*
     require_once 'Crypt/XXTEA.php';
     $cipher = new Crypt_XXTEA();
     $cipher->setKey($salt);
     $password = $cipher->decrypt($password);
     */
     require_once 'Crypt/rc4.php';
     $password = rc4Encrypt($salt, $password);
     // Put the username/password in POST fields where the authentication module
     // expects to find them:
     $_POST['username'] = $_GET['username'];
     $_POST['password'] = $password;
     // Authenticate the user:
     $user = UserAccount::login();
     if (PEAR_Singleton::isError($user)) {
         return 'Error';
     } else {
         return 'True';
     }
 }
Exemplo n.º 15
0
 public static function Authenticate($intModuleId = null)
 {
     if (array_key_exists('intUserAccountId', $_SESSION)) {
         $objUserAccount = UserAccount::Load($_SESSION['intUserAccountId']);
         if ($objUserAccount) {
             // Assign the UserAccount object to the globally available QApplication
             QApplication::$objUserAccount = $objUserAccount;
             // If they are not in the admin panel
             if ($intModuleId) {
                 $objRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, $intModuleId);
                 // If they do not have access to this module
                 if (!$objRoleModule->AccessFlag) {
                     QApplication::Redirect('../common/trespass.php');
                 } else {
                     QApplication::$objRoleModule = $objRoleModule;
                 }
             } elseif (!$objUserAccount->AdminFlag) {
                 QApplication::Redirect('../common/trespass.php');
             }
         } else {
             QApplication::Redirect('../common/trespass.php');
         }
     } else {
         QApplication::Redirect('../login.php');
     }
 }
Exemplo n.º 16
0
 /**
  * Process parameters and display the page.
  *
  * @return void
  * @access public
  */
 public function launch()
 {
     global $interface;
     global $configArray;
     // Don't allow account creation if a non-DB authentication method
     // is being used!!
     if ($configArray['Authentication']['method'] !== 'DB') {
         header('Location: Home');
         die;
     }
     if (isset($_POST['submit'])) {
         $result = $this->_processInput();
         if (PEAR::isError($result)) {
             $interface->assign('message', $result->getMessage());
             $interface->assign('formVars', $_POST);
             $interface->setTemplate('account.tpl');
             $interface->display('layout.tpl');
         } else {
             // Now that the account is created, log the user in:
             UserAccount::login();
             header('Location: Home');
             die;
         }
     } else {
         $interface->setPageTitle('User Account');
         $interface->setTemplate('account.tpl');
         $interface->display('layout.tpl');
     }
 }
 /**
  * Sends the details of the support form by email 
  */
 public function processcontactusAction()
 {
     $session = SessionWrapper::getInstance();
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $formvalues = $this->_getAllParams();
     // debugMessage($formvalues);
     $profile = new UserAccount();
     if ($profile->sendContactNotification($formvalues)) {
         // after send events
         $session->setVar(SUCCESS_MESSAGE, "Thank you for contacting us. We shall get back to you shortly.");
         $this->_redirect($this->view->baseUrl('contactus/index/result/success'));
     } else {
         $session->setVar(ERROR_MESSAGE, 'Sorry! An error occured in sending the message. Please try again later ');
         $this->_redirect($this->view->baseUrl('contactus/index/result/error'));
     }
 }
Exemplo n.º 18
0
 public function setup()
 {
     parent::setUp();
     \ACL::create(\CMSAuth::AdministratorRoleName);
     Helper::setupUsers(array(array('login' => self::login, 'password' => self::password, 'rights' => array(\CMSAuth::AdministratorRoleName => true))));
     $user = \UserAccount::getByLogin(self::login);
     \ACL::grant(\CMSAuth::AdministratorRoleName, $user->rights->getEntity());
 }
Exemplo n.º 19
0
 function __construct()
 {
     global $interface;
     global $configArray;
     global $user;
     if (!UserAccount::isLoggedIn()) {
         header("Location: " . $configArray['Site']['path'] . "/MyResearch/Home");
     }
 }
Exemplo n.º 20
0
 /**
  * getting the response
  * 
  * @param UDate $time
  * 
  * @return SimpleXMLElement
  */
 protected function _getResponse(UDate $time)
 {
     Core::setUser(UserAccount::get(UserAccount::ID_SYSTEM_ACCOUNT));
     //TODO
     $response = new SimpleXMLElement('<Response />');
     $response->addAttribute('Time', trim($time));
     $response->addAttribute('TimeZone', trim($time->getTimeZone()->getName()));
     return $response;
 }
Exemplo n.º 21
0
 protected function btnLogin_Click($strFormId, $strControlId, $strParameter)
 {
     $blnError = false;
     $strUsername = $this->txtUsername->Text;
     $strPassword = $this->txtPassword->Text;
     $objUserAccount = UserAccount::LoadByUsername($strUsername);
     $errorMessage = 'Invalid username or password.';
     $objHasher = new PasswordHash(8, PORTABLE_PASSWORDS);
     // Check if that username exists
     if (!$objUserAccount) {
         $blnError = true;
         $this->txtPassword->Warning = $errorMessage;
     } elseif (!$objUserAccount->ActiveFlag) {
         $blnError = true;
         $this->txtPassword->Warning = $errorMessage;
     } elseif (!$objHasher->CheckPassword(sha1($strPassword), $objUserAccount->PasswordHash)) {
         $blnError = true;
         $this->txtPassword->Warning = $errorMessage;
     } else {
         QApplication::Login($objUserAccount);
         $objAssetRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 2);
         $objInventoryRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 3);
         $objContactsRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 4);
         $objShippingRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 5);
         $objReceivingRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 6);
         $objReportsRoleModule = RoleModule::LoadByRoleIdModuleId($objUserAccount->RoleId, 7);
         if (array_key_exists('strReferer', $_GET)) {
             QApplication::Redirect($_GET['strReferer']);
         } else {
             if ($objAssetRoleModule->AccessFlag) {
                 // If the user has access to the assets module, send them there, otherwise...
                 QApplication::Redirect('./assets/');
             } else {
                 if ($objInventoryRoleModule->AccessFlag) {
                     Qapplication::Redirect('./inventory/');
                 } else {
                     if ($objContactsRoleModule->AccessFlag) {
                         Qapplication::Redirect('./contacts/');
                     } else {
                         if ($objShippingRoleModule->AccessFlag) {
                             Qapplication::Redirect('./shipping/');
                         } else {
                             if ($objReceivingRoleModule->AccessFlag) {
                                 Qapplication::Redirect('./receiving/');
                             } else {
                                 if ($objReportsRoleModule->AccessFlag) {
                                     Qapplication::Redirect('./reports/');
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 22
0
 public function testCallApiOperationWithGrants()
 {
     TestsHelper::dbFixture(\UserAccount::getTableName(), array(array('login' => 'test', 'password' => passwordColumn::hash('testtest'))));
     $user = \UserAccount::getById(1);
     \ACL::create(TestApiWithACLOperation::RightName);
     \ACL::grant(TestApiWithACLOperation::RightName, $user->obj_rights->getEntity());
     \UsersLogin::login('test', 'testtest');
     $method = new TestApiWithACLOperation();
     $this->assertTrue($method->exec());
 }
Exemplo n.º 23
0
 protected function Form_Create()
 {
     $strPasswordResetCode = isset($_GET['c']) ? $_GET['c'] : '';
     $this->objUserAccount = UserAccount::LoadByPasswordResetCode($strPasswordResetCode);
     $this->blnValidResetCode = $this->objUserAccount ? true : false;
     $this->lblInstructions_Create();
     $this->txtNewPassword_Create();
     $this->txtNewPassword2_Create();
     $this->btnResetPassword_Create();
 }
Exemplo n.º 24
0
 /**
  * @expectedException \ForbiddenException
  */
 public function testAllRightsChecked()
 {
     $user = \UserAccount::getByLogin(self::loginFixture);
     Acl::grant(self::testReadRight, $user->obj_rights->getEntity());
     UsersLogin::login(self::loginFixture, self::passwordFixture);
     //
     $controller = new TestController();
     $controller->setRequiredRights(array(self::testReadRight, self::testWriteRight));
     $controller->process();
 }
Exemplo n.º 25
0
 public function testRegistration()
 {
     $schema = \CConfig::getSchema(\UsersRegistration::RegistrationConfirmationConfigName);
     $api = new Registration($this->correctForm);
     $api->exec();
     $this->assertTrue($this->mailer->isSent());
     $lastEmail = \EmailLogModel::getLast();
     $this->assertEquals($lastEmail->to->getValue(), self::SomeCorrectEmail);
     $user = \UserAccount::getByLogin(self::NewLogin);
     $this->assertEquals($user->social_networks->getValue()['facebook'], self::NewUID);
 }
Exemplo n.º 26
0
 public function resetPassword($userId, $code)
 {
     $user = UserAccount::getById($userId);
     if ($user->password->getValue() == $code) {
         UsersForgot::resetPassword($user);
         $this->addAlert('Пароль выслан');
     } else {
         $this->addAlert('Токен не найден');
     }
     $this->jump('/');
 }
Exemplo n.º 27
0
 /**
  * Gets the user by id or current user
  *
  * @url GET /$id
  * @url GET /current
  */
 public function getUser($id = null)
 {
     if ($id) {
         $user = UserAccount::get($id);
         // possible user loading method
     } else {
         $user = Core::getUser();
     }
     return $user instanceof UserAccount ? $user->getJson() : array();
     // serializes object into JSON
 }
Exemplo n.º 28
0
 /**
  * constructor
  */
 public function __construct()
 {
     parent::__construct();
     if (!Core::getUser() instanceof UserAccount && get_class($this) !== 'LoginController') {
         if (isset($_REQUEST['user']) && isset($_REQUEST['pass']) && in_array(get_class($this), array('OrderPrintController', 'POPrintController')) && ($userAccount = UserAccount::getUserByUsernameAndPassword(trim($_REQUEST['user']), trim($_REQUEST['pass']), true)) instanceof UserAccount) {
             Core::setUser($userAccount);
         } else {
             $this->getResponse()->Redirect('/login.html');
         }
     }
 }
Exemplo n.º 29
0
 /**
  * Process parameters and display the page.
  *
  * @return void
  * @access public
  */
 public function launch()
 {
     global $interface;
     // Get My Transactions
     if ($patron = UserAccount::catalogLogin()) {
         if (PEAR::isError($patron)) {
             $this->handleCatalogError($patron);
         } else {
             // Renew Items
             if (isset($_POST['renewAll']) || isset($_POST['renewSelected'])) {
                 $renewResult = $this->_renewItems($patron);
             }
             $result = $this->catalog->getMyTransactions($patron);
             if (PEAR::isError($result)) {
                 PEAR::raiseError($result);
             }
             $transList = array();
             foreach ($result as $data) {
                 $current = array('ils_details' => $data);
                 if ($record = $this->db->getRecord($data['id'])) {
                     $formats = isset($record['format']) ? $record['format'] : '';
                     if (!is_array($formats)) {
                         $formats = array($formats);
                     }
                     foreach ($formats as &$format) {
                         $format = preg_replace('/^\\d\\//', '', $format);
                         $format = rtrim($format, "/");
                     }
                     $driver = RecordDriverFactory::initRecordDriver($record);
                     if (!empty($data['title'])) {
                         $title = $data['title'];
                     } else {
                         $title = isset($record['title']) ? $record['title'] : null;
                     }
                     $current += array('id' => $record['id'], 'isbn' => isset($record['isbn']) ? $record['isbn'] : null, 'author' => isset($record['author']) ? $record['author'] : null, 'title' => $title, 'format' => $formats, 'summImages' => $driver ? $driver->getAllImages() : null, 'summThumb' => $driver ? $driver->getThumbnail() : null);
                 }
                 $transList[] = $current;
             }
             if ($this->checkRenew) {
                 $transList = $this->_addRenewDetails($transList);
             }
             $interface->assign('transList', $transList);
             $profile = $this->catalog->getMyProfile($patron);
             if (!PEAR::isError($profile)) {
                 $interface->assign('profile', $profile);
             }
         }
     }
     Login::setupLoginFormVars();
     $interface->setTemplate('checkedout.tpl');
     $interface->setPageTitle('Checked Out Items');
     $interface->display('layout.tpl');
 }
Exemplo n.º 30
0
 public static function setupUsers($data)
 {
     self::dbFixture(\UserAccount::getTableName(), array());
     foreach ($data as $key => $userRow) {
         $userRights = null;
         if (!isset($userRow['password'])) {
             $userRow['password'] = self::DefaultPassword;
         }
         self::checkUserRow($userRow);
         if (isset($userRow['rights'])) {
             $userRights = $userRow['rights'];
         }
         $userRow['password'] = Password::hash($userRow['password']);
         $user = new \UserAccount($userRow);
         $user->insert();
         if (!empty($userRights)) {
             $user->rights = $userRights;
             $user->update();
         }
     }
 }