Skip to content
This repository has been archived by the owner on Feb 13, 2022. It is now read-only.

Question Siler Swoole #681

Open
lookingdown opened this issue May 28, 2021 · 0 comments
Open

Question Siler Swoole #681

lookingdown opened this issue May 28, 2021 · 0 comments

Comments

@lookingdown
Copy link

Hello,
Thanks for very useful libraries, currently using
Siler\Route;
Siler\Swoole;
Siler\Http\Response;
Siler\Http\Request;

With swoole 4.6.7 for a rest API and access controle via JWT (lcobucci/jwt) everything works really great and super efficient.

My question is regarding Swoole\emit ..

I assumed that swoole\emit would exit the execution then and there..

I have this code (parcial):

Route\put('/cockpit/api/{name}/{table}/{id}?/?{idname}?/', function (array $routeParams) use ($apiKey, $validate) {
      
       // This checks against provided JWT token 
       $validate($routeParams['name'], 3);        
 

       $table = $routeParams['table'];
       $id = $routeParams['id'];
       $idname = 'id';
       $update = Update::new($db);
       $update->table($table);
            $data = json_decode(Request\raw(), true)['data'];
       //var_dump($data);
       foreach($data AS $key=>$value){
       $update->columns([
           $key=>$value
       ]);
       }
       $update->where($idname.' =',  $id);
       $pdoStatement = $update->perform();

$validate($routeParams['name'], 3);
results in Swoole\emit('JWT token invalidated by constraints', 401); JWT does not pass..


 if (!$jwtconf->validator()->validate($login, ...$constraints)) {
                    Swoole\emit('JWT token invalidated by constraints', 401);
                } 

returns as expected "401" JWT token invalidated by constraints

BUT the code below $validate() is still execute inspite of Swoole\emit('JWT token invalidated by constraints', 401);
The table is still updated in this case.

Is this expected behaivior.. ??

Thanks
Johan

I just want to know

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant