/** * @param $names * @param callable $cb */ public function check($token, $text, $invalidate = true, $cb) { $e = static::decodeToken($token); if ($e === false) { call_user_func($cb, 'badToken'); return; } list($id, $rnd) = $e; $this->captcha->findOne(function ($t) use($cb, $id, $text, $invalidate) { if (!$t) { call_user_func($cb, 'expired'); return; } Daemon::log(Debug::dump([$invalidate])); if (!$invalidate) { if (strtolower($t['text']) === strtolower($text)) { call_user_func($cb, 'ok'); return; } } $this->captcha->remove(['_id' => new \MongoId($id)], function ($lastError) use($t, $text, $cb) { if ($lastError['n'] !== 1) { call_user_func($cb, 'expired'); return; } if (strtolower($t['text']) !== strtolower($text)) { call_user_func($cb, 'incorrect'); return; } call_user_func($cb, 'ok'); }); }, ['where' => ['_id' => $id, 'rnd' => $rnd, 'ctime' => ['$gt' => time() - 3600]]]); }
/** * @param array $cond * @param callable $cb */ public function remove(array $cond, $cb = null) { $this->externalAuthTokens->remove($cond, $cb); }
/** * @param array $cond * @param callable $cb */ public function remove(array $cond, $cb = null) { $this->externalSignupRequests->remove($cond, $cb); }