public function mfaTokenValidate($iUserId, $sSalt, $sToken, $sIp)
    {
        $oDb = Factory::service('Database');
        $oDb->where('user_id', $iUserId);
        $oDb->where('salt', $sSalt);
        $oDb->where('token', $sToken);

        $oToken  = $oDb->get(NAILS_DB_PREFIX . 'user_auth_two_factor_token')->row();
        $bReturn = true;

        if (!$oToken) {

            $this->setError(lang('auth_twofactor_token_invalid'));
            return false;

        } elseif (strtotime($oToken->expires) <= time()) {

            $this->setError(lang('auth_twofactor_token_expired'));
            $bReturn = false;

        } elseif ($oToken->ip != $sIp) {

            $this->setError(lang('auth_twofactor_token_bad_ip'));
            $bReturn = false;
        }

        //  Delete the token
        $this->mfaTokenDelete($oToken->id);

        return $bReturn;
    }
public function mfaTokenValidate($iUserId, $sSalt, $sToken, $sIp)
    {
        $oDb = Factory::service('Database');
        $oDb->where('user_id', $iUserId);
        $oDb->where('salt', $sSalt);
        $oDb->where('token', $sToken);

        $oToken  = $oDb->get(NAILS_DB_PREFIX . 'user_auth_two_factor_token')->row();
        $bReturn = true;

        if (!$oToken) {

            $this->setError(lang('auth_twofactor_token_invalid'));
            return false;

        } elseif (strtotime($oToken->expires) <= time()) {

            $this->setError(lang('auth_twofactor_token_expired'));
            $bReturn = false;

        } elseif ($oToken->ip != $sIp) {

            $this->setError(lang('auth_twofactor_token_bad_ip'));
            $bReturn = false;
        }

        //  Delete the token
        $this->mfaTokenDelete($oToken->id);

        return $bReturn;
    }
public function mfaTokenValidate ( $ iUserId , $ sSalt , $ sToken , $ sIp ) { $ oDb = Factory :: service ( 'Database' ) ; $ oDb -> where ( 'user_id' , $ iUserId ) ; $ oDb -> where ( 'salt' , $ sSalt ) ; $ oDb -> where ( 'token' , $ sToken ) ; $ oToken = $ oDb -> get ( NAILS_DB_PREFIX . 'user_auth_two_factor_token' ) -> row ( ) ; $ bReturn = true ; if ( ! $ oToken ) { $ this -> setError ( lang ( 'auth_twofactor_token_invalid' ) ) ; return false ; } elseif ( strtotime ( $ oToken -> expires ) <= time ( ) ) { $ this -> setError ( lang ( 'auth_twofactor_token_expired' ) ) ; $ bReturn = false ; } elseif ( $ oToken -> ip != $ sIp ) { $ this -> setError ( lang ( 'auth_twofactor_token_bad_ip' ) ) ; $ bReturn = false ; } //  Delete the token $ this -> mfaTokenDelete ( $ oToken -> id ) ; return $ bReturn ; }
Validate a MFA token

@param  int    $iUserId The ID of the user the token belongs to
@param  string $sSalt   The token's salt
@param  string $sToken  The token's hash
@param  string $sIp     The user's IP address

@return boolean
Validate a MFA token