Skip to content
Snippets Groups Projects
Select Git revision
  • master
  • shib-cas
2 results

Mysql.php

Blame
  • Mysql.php 643 B
    <?php
    
    require_once 'Nmc/Auth/Interface.php';
    
    class Nmc_Auth_Mysql implements Nmc_Auth_Interface
    {
        protected $table;
    
        public function __construct( Zend_Db_Table $table )
        {
            $this->table = $table;
        }
    
    	public function login( $user_name, $password )
    	{
    	    $db = $this->table->getAdapter();
    	    $where = $db->quoteInto('userName=?', $user_name)
    	           . ' AND '
        	       . $db->quoteInto('password=?', md5($password));
    	    $data = $this->table->fetchAll($where);
    		if( count( $data->toArray() ) == 0 ) {
    		    throw new Nmc_Auth_Exception( 'MySQL: userName or password incorrect.');
    		}
    
    		return true;
    	}
    }
    
    ?>