Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class ModelAuth extends AuthAdapter
- {
- /**
- * Modelo a utilizar para el proceso de autenticacion
- *
- * @var String
- */
- protected $_model = 'usuarios';
- /**
- * Asigna el modelo a utilizar
- *
- * @param string $model nombre de modelo
- */
- public function setModel($model)
- {
- $this->_model = $model;
- }
- /**
- * check
- *
- * @param $username
- * @param $password
- * @return bool
- */
- protected function _check ($username, $password)
- {
- // TODO $_SERVER['HTTP_HOST'] puede ser una variable por si quieren ofrecer autenticacion desde cualquier host indicado
- if(strpos($_SERVER['HTTP_REFERER'], $_SERVER['HTTP_HOST']) === FALSE){
- self::log('INTENTO HACK IP '.$_SERVER['HTTP_REFERER']);
- $this->setError('Intento de Hack!');
- return FALSE;
- }
- // TODO: revisar seguridad
- $password = hash($this->_algos, $password);
- //$username = addslashes($username);
- $username = filter_var($username, FILTER_SANITIZE_MAGIC_QUOTES);
- var_dump($username);die;
- $model = Load::model($this->_model);
- if ($model->find_first("$this->_login = '$username' AND $this->_pass = '$password'")) {
- Session::set('id', $model->id);
- Session::set($this->_key, TRUE);
- return TRUE;
- } else {
- $this->setError('Error Login!');
- Session::set($this->_key, FALSE);
- return FALSE;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement