public function isCorrect($iUserId, $sPassword)
    {
        if (empty($iUserId) || empty($sPassword)) {
            return false;
        }

        // --------------------------------------------------------------------------

        $oDb = Factory::service('Database');
        $oDb->select('u.password, u.password_engine, u.salt');
        $oDb->where('u.id', $iUserId);
        $oDb->limit(1);
        $oResult = $oDb->get(NAILS_DB_PREFIX . 'user u');

        // --------------------------------------------------------------------------

        if ($oResult->num_rows() !== 1) {
            return false;
        }

        // --------------------------------------------------------------------------

        /**
         * @todo: use the appropriate driver to determine password correctness, but
         * for now, do it the old way
         */

        $sHash = sha1(sha1($sPassword) . $oResult->row()->salt);

        return $oResult->row()->password === $sHash;
    }
public function isCorrect($iUserId, $sPassword)
    {
        if (empty($iUserId) || empty($sPassword)) {
            return false;
        }

        // --------------------------------------------------------------------------

        $oDb = Factory::service('Database');
        $oDb->select('u.password, u.password_engine, u.salt');
        $oDb->where('u.id', $iUserId);
        $oDb->limit(1);
        $oResult = $oDb->get(NAILS_DB_PREFIX . 'user u');

        // --------------------------------------------------------------------------

        if ($oResult->num_rows() !== 1) {
            return false;
        }

        // --------------------------------------------------------------------------

        /**
         * @todo: use the appropriate driver to determine password correctness, but
         * for now, do it the old way
         */

        $sHash = sha1(sha1($sPassword) . $oResult->row()->salt);

        return $oResult->row()->password === $sHash;
    }
public function isCorrect ( $ iUserId , $ sPassword ) { if ( empty ( $ iUserId ) || empty ( $ sPassword ) ) { return false ; } // -------------------------------------------------------------------------- $ oDb = Factory :: service ( 'Database' ) ; $ oDb -> select ( 'u.password, u.password_engine, u.salt' ) ; $ oDb -> where ( 'u.id' , $ iUserId ) ; $ oDb -> limit ( 1 ) ; $ oResult = $ oDb -> get ( NAILS_DB_PREFIX . 'user u' ) ; // -------------------------------------------------------------------------- if ( $ oResult -> num_rows ( ) !== 1 ) { return false ; } // -------------------------------------------------------------------------- /**
         * @todo: use the appropriate driver to determine password correctness, but
         * for now, do it the old way
         */ $ sHash = sha1 ( sha1 ( $ sPassword ) . $ oResult -> row ( ) -> salt ) ; return $ oResult -> row ( ) -> password === $ sHash ; }
Determines whether a password is correct for a particular user.

@param  int    $iUserId   The user ID to check for
@param  string $sPassword The raw, unencrypted password to check

@return boolean
Determines whether a password is correct for a particular user .