_getTable()->searchBy(['email' => $email], 'id'))) { $this->setPrimaryKey($id); } return $this; } public function setPrimaryKeyByLogin($login) { if (false !== ($id = $this->_getTable()->searchBy(['login' => $login], 'id'))) { $this->setPrimaryKey($id); } return $this; } public function getSecurityQuestion() { $select = $this->_db->select(); $select->from($this->_getPair('UserSecurityQuestion', 'q'), ['title']); $select->join($this->_getPair(null, 'u'), '`u`.`securityQuestionId` = `q`.`id`', []); $select->where('`u`.`id` = ?', (string) $this->getPrimaryKey(), Qs_Db::INT_TYPE); return $this->_db->fetchOne($select); } public function validateSecurityAnswer($answer) { $answer = $this->prepareSecurityAnswer($answer); $dbAnswer = $this->getData('securityAnswer'); if ($answer && $dbAnswer && $answer == $dbAnswer) { return true; } return false; } /** * Set primary key for recover code * * @param string $recoverCode * @return $this * @throws \Exception */ public function setPrimaryKeyByRecoverCode($recoverCode) { if (false !== ($id = $this->_getTable()->searchBy(['recoverCode' => $recoverCode], 'id'))) { $this->setPrimaryKey($id); } return $this; } /** * Set code for password recover * * @param string $recoverCode * @param string $expirationDate * @return Obj */ public function setRecoverCode($recoverCode, $expirationDate) { $updateData = [ 'recoverCode' => $recoverCode, 'recoverCodeExpirationDate' => $expirationDate, ]; $this->_getTable()->updateByKey($updateData, $this->_primaryKey); return $this; } protected function _insertDependency() { return $this; } protected function _updateDependency() { return $this; } protected function _deleteDependency() { return $this; } }