How to compare request data with db?

hi there, i’m trying to implement separated login system to use at API and im using a collection to keep members data for splitting backend users and frontend users.
i need to compare email and password at backend and i tried to use collections.find.before and collections.find.after hooks for it.
i know those can be nested but i don’t know how to get incoming data to compare with db and send response as true or false.

 $app->on('collections.find.before.members', function($name, $options) {
       //need to get posted data here 
    $this->on('collections.find.after.members', function($name, &$entry){
        //need to compare with existing data
        //than alter the response as true or false
        }, -9999);
 }, 9999); 

Thanks in advance for any help

i have solved the problem.i think it is a simple backend validation
now i need to learn to call this with custom endpoint…:slight_smile: :grinning_face_with_smiling_eyes:
the code is below for who may need in future

//run only for api request
if (COCKPIT_API_REQUEST && $app->param('populate', false)) {
         //run only for certain collection "members" here 
        $app->on('collections.find.after.members', function($name, &$entry) {
          //if  matched record found
         if(count($entry) > 0 ){
            //get posted request field
            $requestedField = $this->request->request["filter"]["code"];
             
            //get db response data and extract necessary field
            $responseField = $entry[0]["code"];
             
            //clean default response body
             $entry=[];
            
            //set new field named "isconfirmed" and return comparsation result
            $entry["isconfirmed"]= ($firstField !== $responseField) ?  true :false;
          }else{
                $entry["isconfirmed"]=false;
                $entry["text"]="no record found";
            }
        });
}