本文整理汇总了PHP中Alchemy\Phrasea\Application::requireCaptcha方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::requireCaptcha方法的具体用法?PHP Application::requireCaptcha怎么用?PHP Application::requireCaptcha使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Alchemy\Phrasea\Application
的用法示例。
在下文中一共展示了Application::requireCaptcha方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddCaptcha
public function testAddCaptcha()
{
$app = new Application(Application::ENV_TEST);
$app['conf'] = $this->getMockBuilder('Alchemy\\Phrasea\\Core\\Configuration\\PropertyAccess')->disableOriginalConstructor()->getMock();
$app['conf']->expects($this->any())->method('get')->with(['registry', 'webservices', 'captcha-enabled'])->will($this->returnValue(true));
$this->assertFalse($app->isCaptchaRequired());
$app->requireCaptcha();
$this->assertTrue($app->isCaptchaRequired());
$this->assertFalse($app->isCaptchaRequired());
}
示例2: doAuthentication
private function doAuthentication(PhraseaApplication $app, Request $request, FormInterface $form, $redirector)
{
if (!is_callable($redirector)) {
throw new InvalidArgumentException('Redirector should be callable');
}
$context = new Context(Context::CONTEXT_NATIVE);
$app['dispatcher']->dispatch(PhraseaEvents::PRE_AUTHENTICATE, new PreAuthenticate($request, $context));
$form->bind($request);
if (!$form->isValid()) {
$app->addFlash('error', $app->trans('An unexpected error occured during authentication process, please contact an admin'));
throw new AuthenticationException(call_user_func($redirector));
}
$params = [];
if (null !== ($redirect = $request->get('redirect'))) {
$params['redirect'] = ltrim($redirect, '/');
}
try {
$usr_id = $app['auth.native']->getUsrId($request->request->get('login'), $request->request->get('password'), $request);
} catch (RequireCaptchaException $e) {
$app->requireCaptcha();
$app->addFlash('warning', $app->trans('Please fill the captcha'));
throw new AuthenticationException(call_user_func($redirector, $params));
} catch (AccountLockedException $e) {
$app->addFlash('warning', $app->trans('login::erreur: Vous n\'avez pas confirme votre email'));
$app->addUnlockAccountData($e->getUsrId());
throw new AuthenticationException(call_user_func($redirector, $params));
}
if (null === $usr_id) {
$app['session']->getFlashBag()->set('error', $app->trans('login::erreur: Erreur d\'authentification'));
throw new AuthenticationException(call_user_func($redirector, $params));
}
$user = $app['manipulator.user']->getRepository()->find($usr_id);
$session = $this->postAuthProcess($app, $user);
$response = $this->generateAuthResponse($app, $app['browser'], $request->request->get('redirect'));
$response->headers->clearCookie('invite-usr-id');
if ($request->cookies->has('postlog') && $request->cookies->get('postlog') == '1') {
if (!$user->isGuest() && $request->cookies->has('invite-usr_id')) {
if ($user->getId() != ($inviteUsrId = $request->cookies->get('invite-usr_id'))) {
$repo = $app['EM']->getRepository('Phraseanet:Basket');
$baskets = $repo->findBy(['usr_id' => $inviteUsrId]);
foreach ($baskets as $basket) {
$basket->setUser($user);
$app['EM']->persist($basket);
}
}
}
}
if ($request->request->get('remember-me') == '1') {
$nonce = \random::generatePassword(16);
$string = $app['browser']->getBrowser() . '_' . $app['browser']->getPlatform();
$token = $app['auth.password-encoder']->encodePassword($string, $nonce);
$session->setToken($token)->setNonce($nonce);
$response->headers->setCookie(new Cookie('persistent', $token));
$app['EM']->persist($session);
$app['EM']->flush();
}
$event = new PostAuthenticate($request, $response, $user, $context);
$app['dispatcher']->dispatch(PhraseaEvents::POST_AUTHENTICATE, $event);
return $event->getResponse();
}