当前位置: 首页>>代码示例>>PHP>>正文


PHP AuthenticationException::getMessageKey方法代码示例

本文整理汇总了PHP中Symfony\Component\Security\Core\Exception\AuthenticationException::getMessageKey方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthenticationException::getMessageKey方法的具体用法?PHP AuthenticationException::getMessageKey怎么用?PHP AuthenticationException::getMessageKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Security\Core\Exception\AuthenticationException的用法示例。


在下文中一共展示了AuthenticationException::getMessageKey方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onAuthenticationFailure

 /**
  * {@inheritdoc}
  */
 public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
 {
     if ($request->isXmlHttpRequest()) {
         return new JsonResponse(['success' => false, 'message' => $exception->getMessageKey()], 401);
     }
     return parent::onAuthenticationFailure($request, $exception);
 }
开发者ID:gabiudrescu,项目名称:Sylius,代码行数:10,代码来源:AuthenticationFailureHandler.php

示例2: start

 public function start(Request $request, AuthenticationException $authException = null)
 {
     $apiProblem = new ApiProblem(Response::HTTP_UNAUTHORIZED);
     $message = $authException ? $authException->getMessageKey() : 'Missing credentials';
     $apiProblem->set('detail', $message);
     return $this->responseFactory->createResponse($apiProblem);
 }
开发者ID:C3-TKO,项目名称:smash-api,代码行数:7,代码来源:JWTTokenAuthenticator.php

示例3: onAuthenticationFailure

 public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
 {
     return new JsonResponse(
         // you could translate the message
         array('message' => $exception->getMessageKey()),
         403
     );
 }
开发者ID:romainbellande,项目名称:iim-notes,代码行数:8,代码来源:ApiTokenAuthenticator.php

示例4: onAuthenticationFailure

 /**
  * NOTE: I chose to throw an HTTP Exception here to let the response be rendered elsewhere -
  *       separation of concerns and all... You could always return a JsonResponse here.
  */
 public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
 {
     $message = 'Invalid Credentials';
     if ($exception instanceof CustomUserMessageAuthenticationException) {
         $message = $exception->getMessageKey();
     }
     throw new HttpException(401, $message);
 }
开发者ID:tuimedia,项目名称:forum,代码行数:12,代码来源:JWTAuthenticator.php

示例5: 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);
 }
开发者ID:robstoll,项目名称:PuMa,代码行数:12,代码来源:AuthFailureHandler.php

示例6: onAuthenticationFailure

 public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
 {
     if ($request->isXmlHttpRequest()) {
         $message = $exception->getMessageKey();
         $messageTrans = $this->translator->trans($message, array(), 'FOSUserBundle');
         if ($messageTrans === $message) {
             $messageTrans = $this->translator->trans($message, array(), 'security');
         }
         $data = array('message' => $messageTrans);
         $response = new \Symfony\Component\HttpFoundation\JsonResponse($data, 400);
         return $response;
     } else {
         return parent::onAuthenticationFailure($request, $exception);
     }
 }
开发者ID:bambamboole,项目名称:AjaxFOSUserBundle,代码行数:15,代码来源:AuthenticationFailureHandler.php

示例7: onAuthenticationFailure

 public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
 {
     // TODO: Implement onAuthenticationFailure() method.
     return new JsonResponse(array('message' => $exception->getMessageKey()), 403);
 }
开发者ID:Benjamin57,项目名称:iim-notes-DARCET-ACHEEN-CARCAGNO,代码行数:5,代码来源:ApiTokenAuthenticator.php

示例8:

 function it_returns_json_response_if_request_is_xml_based(Request $request, AuthenticationException $authenticationException)
 {
     $request->isXmlHttpRequest()->willReturn(true);
     $authenticationException->getMessageKey()->willReturn('Invalid credentials.');
     $this->onAuthenticationFailure($request, $authenticationException)->shouldHaveType(JsonResponse::class);
 }
开发者ID:loic425,项目名称:Sylius,代码行数:6,代码来源:AuthenticationFailureHandlerSpec.php

示例9: onAuthenticationFailure

 public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
 {
     throw new \Exception();
     return new Response(strtr($exception->getMessageKey(), $exception->getMessageData()), 403);
 }
开发者ID:koala-framework,项目名称:koala-framework,代码行数:5,代码来源:KwfUserAuthenticator.php

示例10: getMessageKey

 public function getMessageKey()
 {
     return $this->messageKey !== null ? $this->messageKey : parent::getMessageKey();
 }
开发者ID:Irvyne,项目名称:KnpUGuard,代码行数:4,代码来源:CustomAuthenticationException.php

示例11: createResponseFromException

 /**
  * Create a proper json response containing the error.
  *
  * @param AuthenticationException $authException The exception that started the authentication process.
  *
  * @return JsonResponse
  */
 private function createResponseFromException(AuthenticationException $authException = null)
 {
     $data = ['status' => 'unauthorized'];
     if ($authException) {
         $data['message'] = $authException->getMessageKey();
     }
     return new JsonResponse($data, JsonResponse::HTTP_UNAUTHORIZED);
 }
开发者ID:contao,项目名称:package-manager,代码行数:15,代码来源:PostDataAuthenticator.php

示例12: 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

示例13: 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);
 }
开发者ID:coresite,项目名称:apiauthbundle,代码行数:15,代码来源:ApiKeyAuthenticator.php

示例14: onAuthenticationFailure

 /**
  * @inheritDoc
  */
 public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
 {
     return new JsonResponse(['message' => $exception->getMessageKey()], 401);
 }
开发者ID:ampisoft,项目名称:user-bundle,代码行数:7,代码来源:ApiTokenAuthenticator.php

示例15: onAuthenticationFailure

 public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
 {
     $data = array('message' => strtr($exception->getMessageKey(), $exception->getMessageData()));
     return new JsonResponse($data, 403);
 }
开发者ID:sujit13666,项目名称:SymfonyCRUD,代码行数:5,代码来源:TokenAuthenticator.php


注:本文中的Symfony\Component\Security\Core\Exception\AuthenticationException::getMessageKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。