本文整理汇总了PHP中Symfony\Component\Security\Core\Exception\AuthenticationException::getMessageData方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthenticationException::getMessageData方法的具体用法?PHP AuthenticationException::getMessageData怎么用?PHP AuthenticationException::getMessageData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Security\Core\Exception\AuthenticationException
的用法示例。
在下文中一共展示了AuthenticationException::getMessageData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onAuthenticationFailure
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
{
if ($request->isXmlHttpRequest()) {
if ($this->env != 'dev') {
$msg = $this->translator->trans($exception->getMessageKey(), $exception->getMessageData(), 'security');
} else {
$msg = $exception->getMessage();
}
return new JsonResponse($msg, Response::HTTP_UNAUTHORIZED);
}
return parent::onAuthenticationFailure($request, $exception);
}
示例2: onAuthenticationFailure
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
{
$data = array('message' => strtr($exception->getMessageKey(), $exception->getMessageData()));
return new JsonResponse($data, 403);
}
示例3: onAuthenticationFailure
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
{
throw new \Exception();
return new Response(strtr($exception->getMessageKey(), $exception->getMessageData()), 403);
}
示例4: getMessageData
public function getMessageData()
{
return $this->messageData !== null ? $this->messageData : parent::getMessageData();
}
示例5: getMessage
/**
* Gets the message from the specific AuthenticationException and then
* translates it. The translation process allows us to customize the
* messages we want - see the translations/en.yml file.
*/
private function getMessage(AuthenticationException $authException = null)
{
$key = $authException ? $authException->getMessageKey() : 'authentication_required';
$parameters = $authException ? $authException->getMessageData() : array();
return $this->translator->trans($key, $parameters);
}
示例6: onAuthenticationFailure
/**
* This is called when an interactive authentication attempt fails. This is
* called by authentication listeners inheriting from
* AbstractAuthenticationListener.
*
* @param Request $request
* @param AuthenticationException $exception
*
* @return Response The response to return, never null
*/
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
{
$data = array('code' => self::RESPONSE_FAILURE_CODE, 'message' => strtr($exception->getMessageKey(), $exception->getMessageData()));
return new JsonResponse($data, self::RESPONSE_FAILURE_CODE);
}
示例7: onAuthenticationFailure
/**
* Called when authentication executed, but failed (e.g. wrong username password).
*
* This should return the Response sent back to the user, like a
* RedirectResponse to the login page or a 403 response.
*
* If you return null, the request will continue, but the user will
* not be authenticated. This is probably not what you want to do.
*
* @param Request $request
* @param AuthenticationException $exception
*
* @return Response|null
*/
public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
{
return new JsonResponse(['message' => $this->translator->trans($exception->getMessageKey(), $exception->getMessageData())], 403);
}
开发者ID:robertdumitrescu,项目名称:Interview-MusicCoursesApplication,代码行数:18,代码来源:TokenAuthenticatorService.php