Пример #1
0
 public function testOnVerifiedHook()
 {
     // use a closure to ensure hook being executed
     $count = 42;
     Cloud::onVerified("sms", function ($user) use(&$count) {
         $count += 1;
     });
     Cloud::runOnVerified("sms", null);
     $this->assertEquals(43, $count);
 }
Пример #2
0
 /**
  * Dispatch onVerified hook
  *
  * @param string $type Verify type: email or sms
  * @param array  $body JSON decoded body params
  */
 private function dispatchOnVerified($type, $body)
 {
     $userObj = LeanClient::decode($body["object"], null);
     LeanUser::saveCurrentUser($userObj);
     $meta["remoteAddress"] = $this->env["REMOTE_ADDR"];
     try {
         Cloud::runOnVerified($type, $userObj, $meta);
     } catch (FunctionError $err) {
         $this->renderError($err->getMessage(), $err->getCode());
     }
     $this->renderJSON(array("result" => "ok"));
 }
Пример #3
0
 /**
  * Dispatch onVerified hook
  *
  * @param string $type Verify type: email or sms
  * @param array  $body JSON decoded body params
  */
 private function dispatchOnVerified($type, $body)
 {
     if (!Client::verifyHookSign("__on_verified_{$type}", $body["object"]["__sign"])) {
         error_log("Invalid hook sign for onVerified {$type}" . " from {$this->env['REMOTE_ADDR']}");
         $this->renderError("Unauthorized.", 401, 401);
     }
     $userObj = Client::decode($body["object"], null);
     User::saveCurrentUser($userObj);
     $meta["remoteAddress"] = $this->env["REMOTE_ADDR"];
     try {
         Cloud::runOnVerified($type, $userObj, $meta);
     } catch (FunctionError $err) {
         $this->renderError($err->getMessage(), $err->getCode());
     }
     $this->renderJSON(array("result" => "ok"));
 }