Jump to content

ApiKeys insert twice


ViroManchego

Recommended Posts

 this code on a plugin event 
 

 public function preAction($event)
    { 
Loader::loadModels($this, array("Clients","Companies","ApiKeys","Users"));
   //  $client = $this->Clients->getByUserId(2, true);
    
            $post = [
                'company_id'=>1,
                'user'=>rand(),
                'notes'=>''
            ];
           
        $userKey =  $this->ApiKeys->add($post);
        if (($errors = $this->ApiKeys->errors())) {
            d($errors);
        }
       d( $this->ApiKeys->lastInsertId()); 
}

on refreshing  /admin/settings/system/api/   page  inserts 2 users instead of one

My guess is that preAction event  run twice 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...